Page 1 of 1

Anticollision

Posted: Thu Aug 01, 2002 10:56 pm
by tltrude
I have been trying to figure out a way to keep my two boats from driving through each other on my map. Clip brushes don't work to deflect script objects. So I'm trying a vector move and can't seem to get it right. Any help would be great.

Image

I could make both boats stick to one side of the canal or the other, but that would be bad for gameplay and not what I want. Maybe only the small boat should move out of the way because the riverboat has to go under the bridge in the center. Here is my latest try with the script that failed:

//----------------------------------------------------------->
//Anti-collision threads
//----------------------------------------------------------->

anticollision:

while (vector_length ($boat.origin - $riverboat.origin) <= 200)
{
$riverboat moveWest 200
$riverboat move
$boat moveEast 200
$boat move
}
wait 5

goto anticollision

The two boats have their own docks at either end and will be parked next to each other at one end sometimes. The boats turn around when they reach their docks. Although the riverboat goes past it's dock to turn around.

Image

Posted: Fri Aug 02, 2002 4:08 am
by Moal
I would again use waypoints and triggers
example in if statments

if boatB at waypoint2
trigger check varA to see if it has been set to say 1
by
boatA which has passed waypointB but not waypointC
so boatB stops till boatA triggers WaypointC
set varA to 0 and tell boatB to move again

check your speed of both and see how close they get and
adjust accordingly

or add an extra set of waypoints where they would pass and redirect boatB
to a side path till past a point or till boatA passes it's point

Posted: Sat Aug 03, 2002 6:57 am
by KcAX18
hey tom sorry i cant help with ur boat but that looks like a pritty good map when is it going to be released?

Posted: Mon Aug 12, 2002 8:38 am
by tltrude
I'm still struggling with the anticollision thing. But, the rest of the map is coming along nicely.

Image

Image

Here is my latest try at a the script for anticollision:

//----------------------------------------------------------->
//Anti-collision threads
//----------------------------------------------------------->

counter:

local.distance = vector_length ($riverboat.origin - $boat.origin)
wait 1
if (local.distance <= 250)
{
goto anticolision
}
else
goto counter

//----------------------------------------------------------->

anticollision:

$boat moveWest 250
$boat move
wait 4
$boat moveEast 250
$boat move

end

With this one the boat moves aside, but it stops dead in the water and wont contiue its normal route.

Posted: Tue Aug 13, 2002 1:00 pm
by Moal
at that point I would call orignal script to move boat
that one you used to start trip when player got in boat

Grrrrr!

Posted: Fri Aug 23, 2002 5:58 pm
by tltrude
My map is pretty much done except for this anticollision thing. I got the small boat to move aside for the bigger one, but it wont contiue on it's path after it passes. I think the problem is with the variable name. Are there any rules as to what names you can use?

//----------------------------------------------------------->
//Anti-collision threads
//----------------------------------------------------------->

counter:

local.distance = vector_length ($riverboat_bumper.origin - $boat_bumper.origin)
wait .1
if (local.distance < 64)
{
goto anticollision
}
else
goto counter

end

//----------------------------------------------------------->

anticollision:

$boat moveWest 250
$boat move
wait 4
$boat moveEast 250
$boat waitmove

goto boat_continue

end

//----------------------------------------------------------->

boat_continue:

if (local.boatpos == 0)
{
goto boat_continue_up
}
else
if (local.boatpos == 1)
{
goto boat_continue_down
}

end

//----------------------------------------------------------->

boat_continue_up:

$boat moveto $boat_dock2
$boat time 4
$boat rotateYup 180 // turns the boat around for return trip.
$boat waitmove
$boat speed 150
$boat_wake anim stop
$boat_motor playsound riverboat_snd_off
wait .1
$boat_motor loopsound boat_snd_idle wait
thread counter

goto boat_standby

//----------------------------------------------------------->

boat_continue_down:

$boat moveto $boat_dock1
$boat time 4
$boat rotateYup 180 // turns the boat around for return trip.
$boat waitmove
$boat speed 150
$boat_wake anim stop
$boat_motor playsound riverboat_snd_off
wait .1
$boat_motor loopsound boat_snd_idle wait
thread counter

goto boat_standby

Got it!

Posted: Sun Aug 25, 2002 3:14 am
by tltrude
Never mind, I got it working by adding new position variables to the original path threads (not shown above) and a script origin in front of each boat.