Jump to content

correcting lateral rez of objected based on movement


CynricSaxon
 Share

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

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

Recommended Posts

Needing help figuring this out

 

I have an object that rezzes ammuntion, which currently works as expected in the center of the crosshairs no matter facing direction in mouselook

Some have requested lateral aim correction based on y basically when you stand still it remains to fire dead center mouselook or moving forward or backwards. Correction changes only when moving left or right.  Changing position.y seems to always offset to the + or - of crosshair even when standing still or forward or backwards movement which isnt wanted.

 

Any suggestions or help would be greatful

Link to comment
Share on other sites

If I understood correctly, you want the projectile to "predict" the user's movement by rezzing slightly ahead in the direction they are moving, but only when they are moving sideways. (Or rather, you only want to account for any lateral movement, not forward/backward motion.)

This isn't too difficult, you can get the avatar's velocity with llGetVel, cancel out the avatar's rotation, then check for the Y component. That'll tell you how fast you're moving and to which side. Here's a simple visualizer you can wear:

default
{
    state_entry()
    {
        while (TRUE)
        {
            vector v = llGetVel() / llGetRot();
            vector color = <llFabs(v.x), llFabs(v.y), llFabs(v.z)>;
            llSetText((string)v, color, 1);
            llSleep(0.022);
        }
    }
}

Once you have your velocity, you can use llGetCameraRot (or llGetRot)'s left axis and multiply that by whatever factor you need before adding that as your offset. In simpler terms:

rotation camera = llGetCameraRot();
vector side = <0,1,0> * camera; // Camera's left axis
vector velocity = llGetVel() / llGetRot();

llRezAtRoot("projectile",
    llGetCameraPos() + (side * velocity.y * 0.5),
    <projectile_speed, 0, 0> * camera,
    camera,
    0);

 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

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