# Rotation of a physical object

## Recommended Posts

Hey there, I want a command that will rotate a physical object until it's local z axis is pointing straight up.  Anyone know how to do this?

##### Share on other sites

Hey there, I want a command that will rotate a physical object until it's local z axis is pointing straight up.  Anyone know how to do this?

##### Share on other sites
` llSetLocalRot( llGetLocalRot() * llRotBetween( <0.0, 0.0,1.0> *llGetLocalRot(), <0.0, 0.0,1.0> ) ); `

It doesn't make any difference whether the object is physical or not.  If you want to rotate its Z axis to point uip, that's how to do it.

##### Share on other sites

And if I wanted to point the X axis straight up, would that become

`llSetLocalRot( llGetLocalRot() * llRotBetween( <1.0, 0.0,0.0> *llGetLocalRot(), <0.0, 0.0,1.0> ) );`

And if I wanted to point the Z axis to the left, would that be

`llSetLocalRot( llGetLocalRot() * llRotBetween( <0.0, 0.0,1.0> *llGetLocalRot(), <1.0, 0.0,0.0> ) );`

Just trying to get the format down

##### Share on other sites

That looks right to me.  The best way to be sure is to go in world and test, which I can't do at the moment.

##### Share on other sites

Hmm, I just did.  It didn't do anything

I should point out that this is for a root prim, not a child prim.

##### Share on other sites

I think the problem is that llSetRot and similar don't work on physical prims.

In this instance, the simplest method is to use llLookAt(), since that works with both physical and non-physical objects and points the Z axis (rather than the X axis, which is what most functions use) at the specified position.

So try something like:

`integer toggle;default{	state_entry()	{		llSay(0, "Hello, Avatar!");	}	touch_start(integer total_number)	{		toggle=!toggle;		if(toggle){			llLookAt(llGetPos()+<0.0,0.0,1.0>,1.0,0.1); // look at a point 1 metre above me		}		else{			llStopLookAt(); // turn the lookat off		}	}}`

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.