Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Making a Vehicle Turn It's Angular Motor to a Vector?

Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
01-08-2010 16:05
I'm trying to make a vehicle go to a vector then turn to another vector and go there.

But how can I get the amount to turn the angular motor to go to the vector?

I dont want to use LookAt and MoveTo, cause they don't look at real, with the vehicles paramaters.
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
01-09-2010 10:45
Anyone?

Or even know what kinda Math I would start with?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-09-2010 12:53
I'm not understanding exactly what your attempting. a clearer description perhaps?
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
01-09-2010 14:22
Ok

You have a vehicle set with the paramaters, the angular motor changes the turning.

If I have a vehicle at a random vector and have another vector, I want the vehicle to turn to the vector, but I don't know how to work out, how much to turn the angular motor to make it face the vector I want it to go to.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-09-2010 14:57
are we talking about pre programming the vehicles path? changing the motors direction will not actually turn the vehicle, it'll just give it a new direction of travel.

I don't know of any simple method of turning a vehicle a preset rotation except perhaps by polling from within a control event until the vehicle is facing your target.

for that you'd be getting and storing your desired target, and making changes while polling if it hasn't lined up yet. sorry, I can't offer specific code for that, I don't usually do vehicles.

the slerp algorithm can help with getting intermediate stepped vectors for the polling adjustment though...
https://wiki.secondlife.com/wiki/Slerp

I'd think you'd use llGetRot(), llRotBetween( < 1, 0, 0 >, llVecNorm( targetPos - llGetPos() ) ), and 2 to get the intermediate vector, apply your turn in that direction, then retest. if it's just a vector direction and not a target you can replace the contentents of vecNorm with your vector
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
01-09-2010 17:32
Angular motor will turn tho?

Linear controls the direction of travel.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-09-2010 19:08
angular deflection is very similar to target omega, in that it specifies a rate of change in a direction. but not a target... you could time it, but I'm unsure exactly how it combines with the linear motor or timescale or decay for an exact formula...

I'm guessing at a timescale of 1.0 that a 90deg vector to the left would equal a 90deg turn in 1 second.... if you wanted exactly 90degrees turned you'd presumably set a timer for 90 seconds then cancel the vector... I'm just guessing on that though, no account taken for friction, decay, or the linear motor.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -