Jump to content

Smooth LookAt help needed.


Grid Strom
 Share

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

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

Recommended Posts

This is about the RootPrim movement of scripted pets and animals.

With the innovation of llSetKeyframedMotion scripters can start converting phyical products that used llMoveToTaget to this.

But there is one issue i am notcing there is a complete inability to have scripts that use llSetKeyframedMotion to have a smooth LookAt effect.

Using llLookAt(pos,1.0,1.0);  float strength, float damping dont have any effect because the object is non physical. This results in the object abruptly snapping its rotation to look at its target position this takes away alot of the natural movements.

And using llSetKeyframedMotion([(pos - llGetPos()), rot,10.12],[]); with this example both the pos and rot share the same play time so the object only rotates to %100 once the object gets to its finel frame position making rotation pointless.

And there can only be one instance of llSetKeyframedMotion running per object at once so this example is impossible.

llSetKeyframedMotion([(pos - llGetPos()), ZERO_ROTATION,10.12],[]);
llSetKeyframedMotion([(ZERO_VECTOR, Rot,3.12],[]);

 

Any ideas on how to over come this problem will be greatly appreciated thanks.


 

Link to comment
Share on other sites

You can compute any number of key frames before you call llKeySetFramedMotion()
So you can compute a smooth approach.
I admit it takes a bit of thinking, planning and testing but it can be done:)

The object will not automatically follow a point like the llLookAt() function does
So a general strategy for computing the key frames has to be figured out

What you want in your "impossible" example can be accomplished like this:

llSetKeyframedMotion([(pos - llGetPos()), ZERO_ROTATION,10.12,ZERO_VECTOR, Rot,3.12],[]);

 

Link to comment
Share on other sites

You should probably also take a look at the example lebeled Universal Hinged Motion in 8 Key Frames that is in the LSL wiki at https://wiki.secondlife.com/wiki/LlSetKeyframedMotion .  It's a very nice short example of how to handle a smooth rotation along a path.  I modified it the other day to use in a vehicle that needs to follow a curving path and keep its nose pointed along the path the whole way.

Link to comment
Share on other sites

Thank you very much for the help its working flawlessly I also had no idea you could have more than one set of key frames. This is a very powerful function but your right it needs alot of thinking. If any one is interested the line i finely used was.

llSetKeyframedMotion([ZERO_VECTOR, rot / llGetRootRotation() ,0.12, (pos - llGetPos()), ZERO_ROTATION,10.12],[]);

 

Link to comment
Share on other sites

Yeah, it's a very keen function.  That example I pointed to in my earlier reply is a good illustration of how to use KFM to turn a corner smoothly.  The effect is sort of like what you used to have to do (with much more code) in something like the Smooth Rotating Door Script that Toy Wylie put in the LSL Script Library a couple of years ago.  Essentially, it lets you dissect your rotation into a series of smaller steps that are then pieced together to make a command list for llSetKeyframedMotion . The advantage of doing that is that your rotating object is always heading toward intermediate points along the curve instead of aiming for the end point all the way.  It makes for a much more realistic-looking motion.  The example is written for rotating a box lid around its Y-axis, but with just a little creative finagling you can get it to rotate around Z and include an offset at each step, as you would if you were keeping a train on its tracks.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4494 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...