Jump to content
  • 0

How do I script an object to rez another object and have the object rez right side up?


RikBair23
 Share

You are about to reply to a thread that has been inactive for 4192 days.

Please take a moment to consider if this thread is worth bumping.

Question

4 answers to this question

Recommended Posts

  • 0

If I remember correctly, when one object is rezzed from another, the newly rezzed object is rezzed with rotation relative to the root prim of the first object. Thus, if the root prim is rotated 180 degrees in the X or Y rotation, the object will be rezzed upside down. (I'll test this when I get in-world).

1) Try turning the rezzed object upside down before putting it in the containing object or put a script in the object being rezzed,

2) Put a script in the rezzed object that check and fixes it's rotation in the on_rez() event.

3) Check and adjust the rotation of the root-prim of the object doing the rezzing to make sure it isn't rotation 180 degrees.

 

Link to comment
Share on other sites

  • 0

The function llRezAtRoot looks like this: llRezAtRoot( string inventory, vector position, vector velocity, rotation rot, integer param );

The two parameters that you need to pay attention to here are position and rot.  The position parameter controls where the new object will appear, relative to the center of the rezzer.  Normally, you would specify it as

llGetPos + offset*llGetRot()

so that the new position is defined by the offset from the rezzer's position ( llGetPos() ), corrected for the rotation of the rezzer ( llGetRot() ).  The rot parameter defines the rotation of the new object itself around its own axes.  If it's not to be rotated at all, then you'd write

ZERO_ROTATION

If you want the object to rez upside down, you'd write

llEuler2Rot(<PI,0.0,0.0>)

Taken all together, if you want the object to rez 1.0m in front of the rezzer and upside down, you'd write

llRezAtRoot("My_Object's_Name_Goes_Here", llGetPos() + <1.0,0.0,0.0>*llGetRot(), ZERO_VECTOR, llEuler2Rot(<PI,0.0,0.0>), 0);

 Read more at http://wiki.secondlife.com/wiki/LlRezAtRoot

Link to comment
Share on other sites

  • 0

Just to add a bit to the other answers, the arguments in llRezAtRoot and llRezObject are 

llRezAtRoot(name, position, force, rotation, start parameter);

 As Curious says, the rotation is relative to the rotation of the rezzer.

Now, it's not clear to me what exactly is happening in your example, because I don't know how the rezzer is rotated or precisely what you mean by "upside down" in this context.   

So, what I suggest you do is position the rezzer so it's rotated at ZERO_ROTATION, which in this context means make sure the three numbers in the rotation spinners in the edit box are all at 0.0.   Then position the rezzed object how you want it rotated relative to the rezzer.    Make a note of the numbers in its rotation spinners -- let's call them x, y and z.

Now, in your script, declare a global variable, rotation objectRot, and calculate its value in state entry:

rotation objectRot;default{	state_entry()	{		objectRot = llEuler2Rot(<x,y,z>*DEG_TO_RAD);	}}

 Remember, x, y and z are the values in the rezzed object's rotation spinner.

Then, when you rez the object, you say 

llRezAtRoot(name,position,force,objectRot*llGetRot(),param);

 In this context, *llGetRot()  means "relative to how the rezzer is rotated" (and it has to be objectRot*llGetRot() -- llGetRot()*objectRot means something totally different).

I'm suggesting doing it this way because I'm not sure how things are rotated in your example, and this should correct for whatever unusual circumstances are making the item rez wrongly.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4192 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...