Jump to content

Align vehicle by axes on stop. Script


Sunbleached
 Share

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

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

Recommended Posts

Hello! I have a boat script, but when I stop it remains in the position in which it was at the time of the engine shutdown. How to make it aligned with the X and Y axes? I think it somehow related to llSetVehicleRotationParam.

I found somewhere:

rotation rot = llEuler2Rot(<0, 0, -PI_BY_TWO>);
llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, rot);

this will align the vehicle, but either i put it in wrong place or something else.

Edited by Sunbleached
Link to comment
Share on other sites

5 hours ago, Sunbleached said:

Hello! I have a boat script, but when I stop it remains in the position in which it was at the time of the engine shutdown.

That's what boats normally do. That's what vehicles normally do, both in SL and RL. Why do you want them to align to an axis when you park?

  • Thanks 1
Link to comment
Share on other sites

15 hours ago, Sunbleached said:

How to make it aligned with the X and Y axes?

You could have the parking rotation defined as a global and then when the engine stops, change from physical and then use llSetRot(parkRotation) as the quickest way to do this, but you are then going to have to work out how to return to physical state when the engine starts. (Often boat scripts do this anyway, changing to and from a vehicle when somebody sits in the drivers seat and doesn't get booted out with the "you are not the owner of this vehicle" message. Look for that in your script, chances are you've got the generic boat script.

 

9 hours ago, animats said:

Why do you want them to align to an axis when you park?

If you bring a boat back into a dock or pontoons it's nice to leave it alongside rather than rammed into the jetty at a drunken angle :) I had exactly this problem with a pair of punts I scripted, when not in transit they had to be aligned precisely to the jetty at which they had arrived. they also had to bob up and down semi-convincingly, so the timer activity switched behaviour according to whether the punt was moored or going somewhere. And when it got swallowed by the giant frog from the deeps, well, that was a different state entirely because it and the passengers had to be transported to an island where they were regurgitated before the empty punt bobbed back to the surface to drift slowly back to the jetty and park itself nicely alongside.

  • Thanks 1
Link to comment
Share on other sites

4 hours ago, Profaitchikenz Haiku said:

You could have the parking rotation defined as a global and then when the engine stops, change from physical and then use llSetRot(parkRotation) as the quickest way to do this, but you are then going to have to work out how to return to physical state when the engine starts. (Often boat scripts do this anyway, changing to and from a vehicle when somebody sits in the drivers seat and doesn't get booted out with the "you are not the owner of this vehicle" message. Look for that in your script, chances are you've got the generic boat script.

Thank you very much! that's what i did. but not working yet. can you help please? what am I doing wrong?

rotation parkRotation;

default

/////........... engine stop:

            llSetRot (parkRotation );
            llSetStatus(STATUS_PHYSICS, FALSE);

and I would also like the alignment to happen only by X & Y axes. What should I put instead of Z?

Link to comment
Share on other sites

1 hour ago, Nova Convair said:

If you want to level the boat ...

1st switch off physics then you can use setrot


llSetStatus(STATUS_PHYSICS,FALSE);

vector actrot = llRot2Euler(llGetRot());

llSetRot(llEuler2Rot(<0,0,actrot.z>));

 

Woah!!! Thank you so very very much! It works perfectly!!! Amazing! Just WOW! THANKS!!!!!

Link to comment
Share on other sites

@Nova Convair @Profaitchikenz Haiku

I am very sorry about this... But as it turned out there is still a very little problem. the fact is that my boat has an option to lift the nose. when i hit stop, everything is just perfect! the position is leveled. but if I press the stop at full speed with the nose raised, the position is aligned, of course and its perfect, but when again i hit Start, the boat lifts its nose, as if it were before off and then slowly goes down... Oh, and by the way if speed was too fast it keeps moving after restart... Maybe I should put the same lines before vehicle start? Thank you in advance!

Actually I already tried it but no success...

Edited by Sunbleached
Link to comment
Share on other sites

1 hour ago, Sunbleached said:

but when again i hit Start, the boat lifts its nose, as if it were before off and then slowly goes down...

When you hit stop, reset the nose angle variable to the level value, what you have described is the result of calling the function with the previous angle for a certain gear still assigned to the variable.

Similarly, when you stop, set and variable controlling speed to the appropriate stop or default value.

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Profaitchikenz Haiku said:

When you hit stop, reset the nose angle variable to the level value, what you have described is the result of calling the function with the previous angle for a certain gear still assigned to the variable.

Similarly, when you stop, set and variable controlling speed to the appropriate stop or default value.

Thank you very much! Thats what i got. It works as expected. Did I do it right?

            vector actrot = llRot2Euler(llGetRot());
            llSetRot(llEuler2Rot(<0,0,actrot.z>));
            llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, llEuler2Rot (<0,0,0> ) );
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0,0,0>);

@Profaitchikenz Haiku @Nova Convair Thank you very much again! I got it working!

Edited by Sunbleached
Link to comment
Share on other sites

@Profaitchikenz Haiku @Nova Convair

So everything works fine. with alignment on the axes and the continuation of the movement everything is clear. but here's a question. if I stop during the turn, then when restarting, it keeps turning slightly but noticeable and visible. What parameter will reset the turn?

Edited by Sunbleached
Link to comment
Share on other sites

1 hour ago, Sunbleached said:

What parameter will reset the turn?

Angular velocity. Have a look through the wiki pages for vehicles, you will see there are two types of velocity you can give a vehicle straight-line, and angular which controls how fast and in which direction it is turning. You should find a list of all possible vehicle parameters, but not all of them will be applicable to a boat. 

  • Thanks 1
Link to comment
Share on other sites

            ///Edit start / stop reset
            
            
            ///On Start:
            
            llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <0,0,0>);

            
            ///On Stop:
            
            vector actrot = llRot2Euler(llGetRot());
            llSetRot(llEuler2Rot (<0,0,actrot.z>));
            llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, llEuler2Rot (<0,0,0>));
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0,0,0>);
            
            ///

In fact it works even if i move both last lines to On Start:

            ///On Start:
            
            llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <0,0,0>);

            llSetVehicleRotationParam(VEHICLE_REFERENCE_FRAME, llEuler2Rot (<0,0,0>));
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0,0,0>);

            
            ///On Stop:
            
            vector actrot = llRot2Euler(llGetRot());
            llSetRot(llEuler2Rot (<0,0,actrot.z>));
            
            ///

 

Link to comment
Share on other sites

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