2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
|
01-13-2010 08:01
Hi,
I have a bunch of non-physical autonomous vehicles that use non-physical movement. I want to switch some of these to using physical movement.
I looked into using vehicles, but I want a simpler way of figuring out if the vehicle is where it is supposed to be (rather than setting speed direction, and polling to determine when it gets there).
I looked into llMovetToTarget but its 60m limitation is not good, since some of my vehicles can easily move beyond 60m.
Given my current position (A) and a random target position (B), I know that I can use llVecMag(A-B) to calculate the distance between them.
If the distance between A & B is greater than 60m, how can I change the B vector to some intermediate position that's less than 60m away, but still on the way to B (on the same straight-line path)?
One solution I have now is a loop that increments the current position by some step value - I could use the loop to crawl along until it finds a vector that's 59m away and use llMoveToTarget with that - is there some other way?
|
Jason Keegan
Registered User
Join date: 20 Apr 2004
Posts: 26
|
01-13-2010 08:27
Hi,
I wouldn't really know the answer but if you can work out the total distance could you not make it so if the total distance is greater than 59m then you only move 59m then check total distance again maybe in a while loop?
Just an idea but I think that's what you was already saying in your post.
- Jason
_____________________
Need help understanding Secondlife scripting language? Check here
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
01-13-2010 08:45
Yeah, i had a warp hud that i used to use, i had 4 buttons on it, Home, Skybox, Cam, Stop. hopefully self explanatory. but most of the time my current position and the destination were more than 60m. i ran llMoveToTarget in a while loop. not online to get the exact snippet, but something like warp(vector dest) { float dist = llVecDist(llGetPos(),dest);
while(dist > 0.25) { llMoveToTarget(dest,0.25); dist = llVecDist(llGetPos(),dest); } llStopMoveToTarget(); }
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
01-13-2010 09:14
From: 2fast4u Nabob If the distance between A & B is greater than 60m, how can I change the B vector to some intermediate position that's less than 60m away, but still on the way to B (on the same straight-line path)? float X; desired distance < 60m vector newB = A + X*llVecNorm(B - A );
_____________________
From Studio Dora
|
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
|
01-13-2010 13:03
From: Dora Gustafson float X; desired distance < 60m vector newB = A + X*llVecNorm(B - A ); Thanks Dora - that's exactly what I need. I forgot about energy and how to affects llMoveToTarget, so it looks like it's back to the vehicle route. This will still come in handy. -2fast
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
01-13-2010 19:15
I use llMoveToTarget(). If these are autonomous vehicles, that follow a set path, (like mine). I setup a waypoint system where you start by clearing waypoints (of course), and then, set the first waypoint, drag the object to position 2, set another waypoint, drag to position 3, etc. If the distance between position A and position B is greater than 60 meters simply set a waypoint in between to keep from having waypoints greater than 60 meters apart. I've actually found that by tinkering with the tau and setting waypoints that are ~10 meters apart, then the movement is relatively smooth and it works great. Also, don't set the range in your llTarget too low, I set mine at ~ 1 meter, otherwise the damping slows down the object too much before the at_target() event gets triggered. If you want to see one in action, give me IM when I'm on sometime and I'll show it to you.
|
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
|
01-14-2010 12:53
Thanks Dora, Johan. I got it working. I spent some time learning about vehicles and have flying, pre-programed vehicles that follow a set path using physical movement. llTarget is really handy - I knew of it but did not know that it's so useful! { In case you are interested: I have the vehicle setup as a car, but I can only get it to fly at the moment - my vehicles don't do too well on the ground at the moment  It's a matter of getting everything setup, but I have navigation, movement, and rotation (to face the destination) working now. }
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
01-14-2010 20:07
I know what you mean about driving on the land. The best I've been able to do is set multiple way points to make the turn rather than just the one. That way, the car will turn 2 or 3 times (or more depending on how many waypoints you set) rather than just one creating a 90 degree "turn on the dime" effect you'd get with just one. Maybe give that a try. Another thing to do especially for land vehicles is to inhibit rotation on x and y and only allow z rotation which keeps the car from banking (unless you're looking for that effect with say a hover car that 'hugs' the ground).
|