Jump to content

Object Movement/Trajectory after llRezAtRoot


Creative Starfall
 Share

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

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

Recommended Posts

Hi:

I have an object that I rezz it using llRezAtRoot!

The object is rezz in a certain position/rotation!

The object should start moving (after is rezz) accoring its position and rotation in a linear/smotth movement till certain point, where it should start to make a smooth curve and then it shold down and die (according a time variable)!

I made an image that exaplains better: 

ZZhS06z.jpeg

 

Does anyone knows how to make this script code?

Thank you so much for your help!

Sincerely, Creative

Link to comment
Share on other sites

This should *probably* be on the wanted forum, but using llRezAtRoot with a velocity applied would do the trick. Add a PRIM_TEMP_ON_REZ to the projectile, then you're golden (Note that it wouldn't guarantee the prim would be removed at the 7 second mark, instead it gets removed whenever the region next does a garbage collection cycle (usually a couple times per min))

As for making it rotate when it falls - Linden vehicles do this, but I'm not 100% sure on how to get a non-vehicle object to do that.

Edited by Jenna Huntsman
Link to comment
Share on other sites

4 minutes ago, Jenna Huntsman said:

This should *probably* be on the wanted forum, but using llRezAtRoot with a velocity applied would do the trick. Add a PRIM_TEMP_ON_REZ to the projectile, then you're golden (Note that it wouldn't guarantee the prim would be removed at the 7 second mark, instead it gets removed whenever the region next does a garbage collection cycle (usually a couple times per min))

As for making it rotate when it falls - Linden vehicles do this, but I'm not 100% sure on how to get a non-vehicle object to do that.

Hi Jenna, thank you for your reply!

I used the following:

Quote

llRezAtRoot(OBJ, pos, <0, 0, 20>*rot, rot, 7);

Honestly I didn't like the result! The object comes out with a lot of speed, and if I put a low speed the object doesn't go up, well, it's a real stress!
Also, the object dont rotate correctly when it starts fall :(
Hence having to find out another solution, where the I can control better the movement using some variables values!

Link to comment
Share on other sites

1 hour ago, Creative Starfall said:

Also, the object dont rotate correctly when it starts fall :(

You may find this solution of interest (essentially, make the object a vehicle, which in turn allows it's rotation to follow the velocity.)

 

1 hour ago, Creative Starfall said:

Honestly I didn't like the result! The object comes out with a lot of speed, and if I put a low speed the object doesn't go up, well, it's a real stress!

You might find manipulating llSetBuoyancy of interest here, essentially allowing you to manipulate how gravity affects an object.

Alternately, manipulate the velocity vector. SL gravity is a pull of 9.8 m/s on the -Z axis, so +20 is quite high.

Edit: This should also be multiplied by the mass of the object, as that also factors in to it's acceleration

Edited by Jenna Huntsman
  • Like 1
Link to comment
Share on other sites

13 minutes ago, Jenna Huntsman said:

SL gravity is a pull of 9.8 m/s on the -Z axis

Gravity is modifiable per object. in this case, setting it to zero for the projectile is probably what would make the most sense.

llSetPhysicsMaterial(8,gravity,0,0,0); is preferable to llSetBuoyancy in pretty much any circumstance I can think of.

13 minutes ago, Jenna Huntsman said:

allows it's rotation to follow the velocity.

llLookAt(llGetPos()+llGetVel(),0.5,0.5);

or

rotation rot = llGetRot();
vector X = llGetVel();
vector Z = <0,0,1>*rot;
vector Y = Z%X;
Z = X%Y;
llRotLookAt(llAxesToRot(X,Y,Z),0.5,0.5);

in a timer (untested).

Edited by Quistess Alpha
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

16 minutes ago, Quistess Alpha said:

Gravity is modifiable per object. in this case, setting it to zero for the projectile is probably what would make the most sense.

llSetPhysicsMaterial(8,gravity,0,0,0); is preferable to llSetBuoyancy in pretty much any circumstance I can think of.

Neat! Can't say I've ever used that function before.

I think I'd probably prefer using the vehicle method to make the projectile follow the velocity though, as it'd be a lot smoother (and less intensive) than having to run a fast timer.

  • Like 1
Link to comment
Share on other sites

23 minutes ago, Quistess Alpha said:

Gravity is modifiable per object. in this case, setting it to zero for the projectile is probably what would make the most sense.

llSetPhysicsMaterial(8,gravity,0,0,0); is preferable to llSetBuoyancy in pretty much any circumstance I can think of.

llLookAt(llGetPos()+llGetVel(),0.5,0.5);

or

rotation rot = llGetRot();
vector X = llGetVel();
vector Z = <0,0,1>*rot;
vector Y = Z%X;
Z = X%Y;
llRotLookAt(llAxesToRot(X,Y,Z),0.5,0.5);

in a timer (untested).

 

Thank you for your help!

I tried this code:

Quote

 

integer TDie = 7; // secs
integer tTDie;

default
{
    state_entry()
    {
        llSetStatus(STATUS_PHYSICS, TRUE);
        llSetTimerEvent(1.0);
    }
    
    timer()
    {
        tTDie=tTDie+1;
        if (tTDie>TDie-1) llDie();
        
        llLookAt(llGetPos()+llGetVel(),0.5,0.5);
        rotation rot = llGetRot();
        vector X = llGetVel();
        vector Z = <0,0,1>*rot;
        vector Y = Z%X;
        Z = X%Y;
        llRotLookAt(llAxesToRot(X,Y,Z), 0.5, 0.5); <------------------------------- ERROR
    }
    
}

 

It gives an error 😞

Link to comment
Share on other sites

1 minute ago, Jenna Huntsman said:

I think I'd probably prefer using the vehicle method to make the projectile follow the velocity though, as it'd be a lot smoother (and less intensive) than having to run a fast timer.

That or just using KFM instead of trying to game the physics system.

As for smoothness, llRotLookAt() is smooth and physics based, so it can look decent on the slower side of fast timers (0.5 seconds or so?). You also have to remember that just because you don't ~See the code behind the vehicle functions, doesn't mean it doesn't exist. somewhere the server has to set the rotation of the object, whether that's explicitly by your code, or implicitly behind a vehicle function system.

  • Like 1
Link to comment
Share on other sites

6 minutes ago, Quistess Alpha said:

You also have to remember that just because you don't ~See the code behind the vehicle functions, doesn't mean it doesn't exist. somewhere the server has to set the rotation of the object, whether that's explicitly by your code, or implicitly behind a vehicle function system.

It does, but in order for a non-physics based solution to be comparable to a physics based solution, it has to set it's rotation more than 45 frames per second (assuming the region is running at full speed), which equates to a delta time of 0.02222222222, so a pretty fast timer. The physics simulation runs regardless, so it's a minor bump in load to the physics engine, but reduces script time by a fair degree.

  • Like 1
Link to comment
Share on other sites

Quote

 

float   Velocity   = 20;
integer CurveAfter =  4; // secs
integer DieAfter   =  7; // secs
integer tTDie;

default
{
    state_entry()
    {
        llSetStatus(STATUS_PHYSICS, TRUE);
        llSetTimerEvent(1.0);
    }
    
    timer()
    {
        tTDie=tTDie+1;
        if (tTDie>DieAfter-1) llDie();
        
        llLookAt(llGetPos() + llGetVel(), 0.5, 0.5);
        rotation rot = llGetRot();
        vector X = llGetVel();
        vector Z = <0,0,1> * rot;
        vector Y = Z%X;
        Z = X%Y;
        llRotLookAt(llAxes2Rot(X,Y,Z), 0.5, 0.5);
    }
    
}

 

Thank you for your help!

I'm trying to get somewhere with Velocity, CurveAfter and DieAfter variables!

Link to comment
Share on other sites

integer gAccumulator;
integer gGravityPoint = 14;
default
{
    state_entry()
    {
        llSetPhysicsMaterial(8,0,0,0,0); // 0 gravity.
        llSetStatus(STATUS_PHYSICS, FALSE);
        // llLookAt is Z-forward, axis crossing example is X-forward.
        //llSetRot(llEuler2Rot(<12,0,0>*DEG_TO_RAD)); // specific initial orientation for testing.
        llSetRot(llEuler2Rot(<292.5,0,270>*DEG_TO_RAD)); // specific initial orientation for testing.
        
        llSetStatus(STATUS_PHYSICS, TRUE);
        
        //llSetVelocity(<0,0,1>,TRUE);
        llSetVelocity(<1,0,0>,TRUE); 
        
        llSetTimerEvent(0.2);
    }
    timer()
    {   if(++gAccumulator==gGravityPoint)
        {   llSetPhysicsMaterial(8,0.1,0,0,0);
            llSay(0,"Gravity on.");
        }
        
        //llLookAt(llGetPos()+llGetVel(),0.2,0.2);
        
        rotation rot = llGetRot();
        vector X = llVecNorm(llGetVel());
        //vector Z = <0,0,1>*rot; // different order seems to givve a slightly nicer result:
        //vector Y = Z%X;
        //Z = X%Y;
        vector Y = <0,1,0>*rot;
        vector Z = X%Y;
        Y = Z%X;
        llRotLookAt(llAxes2Rot(X,Y,Z), 0.2, 0.2);
    }   
}

The bouncing box after it lands is actually kinda fun. . .

Link to comment
Share on other sites

5 minutes ago, Quistess Alpha said:
integer gAccumulator;
integer gGravityPoint = 14;
default
{
    state_entry()
    {
        llSetPhysicsMaterial(8,0,0,0,0); // 0 gravity.
        llSetStatus(STATUS_PHYSICS, FALSE);
        // llLookAt is Z-forward, axis crossing example is X-forward.
        //llSetRot(llEuler2Rot(<12,0,0>*DEG_TO_RAD)); // specific initial orientation for testing.
        llSetRot(llEuler2Rot(<292.5,0,270>*DEG_TO_RAD)); // specific initial orientation for testing.
        
        llSetStatus(STATUS_PHYSICS, TRUE);
        
        //llSetVelocity(<0,0,1>,TRUE);
        llSetVelocity(<1,0,0>,TRUE); 
        
        llSetTimerEvent(0.2);
    }
    timer()
    {   if(++gAccumulator==gGravityPoint)
        {   llSetPhysicsMaterial(8,0.1,0,0,0);
            llSay(0,"Gravity on.");
        }
        
        //llLookAt(llGetPos()+llGetVel(),0.2,0.2);
        
        rotation rot = llGetRot();
        vector X = llVecNorm(llGetVel());
        //vector Z = <0,0,1>*rot; // different order seems to givve a slightly nicer result:
        //vector Y = Z%X;
        //Z = X%Y;
        vector Y = <0,1,0>*rot;
        vector Z = X%Y;
        Y = Z%X;
        llRotLookAt(llAxes2Rot(X,Y,Z), 0.2, 0.2);
    }   
}

The bouncing box after it lands is actually kinda fun. . .

Ty for share!

The object seems to floating instead move straight!😛

Link to comment
Share on other sites

1 minute ago, Quistess Alpha said:

Oh nice! Ty for share Tessa!

Its possible to include these variables?

float   Velocity   = 20;
integer CurveAfter =  4; // secs
integer DieAfter   =  7; // secs

 

It needs to die right after the arc (some seconds after falling)!

Also, the object is rez with this line code: llRezAtRoot(OBJ, pos, <0, 0, 20>*rot, rot, 7);, so it has a velocity when rez!

I'm not sure if it can interfere with you code! :(

Link to comment
Share on other sites

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