Jump to content

Direction for Keyframed motion


ToriBlack77
 Share

Recommended Posts

i'll try to explain as good as i can :)

example - i have arrow. with keyframedmotion script in that moves it across X axis forward for some 2meters. but if i rotate arrow on 90 degrees over Z axis(by hands), arrow will be moving across X axis but pointing wrong direction(to Y axis).

How can i fix that? I tried to understand what is llGetRot and Euler... but im stupid, cant figure out.

I need my arrow move on touch where its pointing. so if arrow pointing +X axis then move +X. if pointing -X, then -X. if -Y then -Y... etc. help me please :) how to get this direction into keyframed motion function?

Link to comment
Share on other sites

llSetKeyframedMotion moves your object in local coordinates, relative to its current position.  So if you tell it to move <1.0,0.0,0.0>, it will move 1 meter in whatever direction its own +X axis is pointing.  Same thing with rotation.  If you want to rotate 90 degrees around Z from its current rotation, you simply tell it to rotate llEuler2Rot(<0.0,0.0,PI/2>) .

In your case, you want to rotate first, then move, so you do it in two steps:

llSetKeyframedMotion([ZERO_VECTOR,llEuler2Rot(<01.0,0.0,PI/2>),1.0,<1.0,0.0,0.0>,ZERO_ROTATION,1.0],[]);

 

Link to comment
Share on other sites

Thank you Rolin but as i understand, position is global, and rotation is local. i dont need to rotate object in motion, i just need its move always where object facing.

I describe in steps what i mean.

Object shaped as arrow, i rez it, and its sharp side(cone side ==>) pointing to +x axis as standard.

llSetKeyframedMotion([<1.0,0.0,0.0>,ZERO_ROTATION,1.0,[]);

 this will move my arrow in +x asxis as supposed to, by sharp side forward. BUT if i rotate BY HANDS :) in Edit menu my arrow 90 degrees left, now arrow pointing to +Y. Code above still move it by X axis. I tesed it. And my arrow moves X asxis with its right side. But i need it move strictly, always to direction where my arrow(object) pointing ==> sharp side.

wiki says:

Translation is in Global coordinates, the Rotation in Local coordinates.

Simply - how to make Global coordinates to be Local? :) 

Link to comment
Share on other sites

I apologize.  You are right.  Translations are global, which simply means that you need to correct each one by the current global rotation.

default{    touch_start(integer total_number)    {        llSetKeyframedMotion([<1.0,0.0,0.0>*llGetRot(),ZERO_ROTATION,2.0,ZERO_VECTOR,llEuler2Rot(<0.0,0.0,PI/2>),2.0],[]);    }}

 

Link to comment
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...