Jump to content
Shanbo Baddingham

Making an object face the direction it's travelling

Recommended Posts

Hi there.  I''m  making a script where a non-physical sculptie in the shape of a floating skull is wandering around.  Problem, is the skull is facing a direction different from the direction it's travelling.  I tried llLookAt, but the skull then moves around it's z-axis, meaning it's top is pointed toward the destination instead of the face.   Anyone know how to make it so that it's oriented correctly, or how to find a rotation to make it face the right direction?

  • Like 1

Share this post


Link to post
Share on other sites

Try using llRotLookAt instead.  There's even an illustrative code snippet on the wiki page that can point you in the right direction.

  • Like 3

Share this post


Link to post
Share on other sites

Since you're using a sculptie, I suspect that the sculpt's own axes aren't aligned with those of a conventional prim -- that is, that when you look at your sculpt in the editor using the local ruler (as opposed to the default world one) the red arrow isn't pointing in the same direction in which the skull is looking.

If that's the case, then the problem is that, by default, LSL assumes that moving forwards means moving on the object's positive x axis.  

The simplest solution by far, if that's the problem, is to put your scripts in a small cube prim, make it invisible and then link your skull sculptie to it as a child prim.  Adjust the skull so it's looking forwards along the root prim's positive x axis, and all should be well.

 

  • Like 4

Share this post


Link to post
Share on other sites

I have exactly the item you're making. Well, more or less; it's a floating skull. Mine also talks via chat commands, poofs when out of range, and dies on command for easy cleanup. I use it to raise eyebrows sometimes at Avilion... it's kinda creepy tho. His name is Crudrick Halfnutsz, late Duke of Noob'ry, lol. He doesn't just wander, but follows me, and he used to follow anyone who got within range, like a zombie NPC or something.

Here's how I sorted my two issues with the facing and movement of a human skull (which I definitely had issues with, as it was mesh and mesh acts funky sometimes):

First off, he didn't want to move smoothly until I encased him in a cylindrical prim (set to transparent and linked as root) and set the skull inside to the height I wanted. Basically what Innula reccommended up there ^. Before that he either skipped across the ground or sort of tumbled in the air, so this sorted that issue.

Secondly, the only way I could get him to face the proper direction otherwise was to orient him correctly before uploading, so he came in facing East. Then even the simplest follower script would put him facing me when he moves. But even this isn't necessary using the transparent prim method above. Plus the movement is smoother.

I know it's a tad redundant, but I had to chime in, as it's about something dear to my heart: decapitated skulls floating around and stalking me. xD

Edited by Berksey
  • Like 1

Share this post


Link to post
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.


×
×
  • Create New...