Jump to content
Sunbleached

Align vehicle by axes on stop. Script

Recommended Posts

Posted (edited)

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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

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>));

 

  • Thanks 1

Share this post


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

Share this post


Link to post
Share on other sites
Posted (edited)

@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

Share this post


Link to post
Share on other sites

 

Of course i could add script reset but the problem is boat has lights and i am afraid lights will go out in this case.

Share this post


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

Share this post


Link to post
Share on other sites
Posted (edited)
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

Share this post


Link to post
Share on other sites
Posted (edited)

@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

Share this post


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

Share this post


Link to post
Share on other sites
Posted (edited)

@Profaitchikenz Haiku llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <0,0,0>); unfortunately dont work...

Addition. in general, that's what I did. placed this line instead of the stop at the start. so when you start everything works fine! Thank you!

I hope this will help to somebody!

Edited by Sunbleached

Share this post


Link to post
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>));
            
            ///

 

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...