Jump to content
FirstPanic

AI can not drive on wooden bridges on Tanoa

Recommended Posts

Hi all,

 

I have big issue on Tanoa and hope that someone finds a workarround for this: It seems that with the current version (1.66) it's not possible to let AI drive (e.g. in jeeps) on wooden bridges. They stop on the bridge and/or fall from it and cannot handle the path finding. This has been reported many times in the feedback tracker but no answer or reactions from developer.

 

Actually this issue means that it's nearly impossible to have jeep/car patrols on tanoa because there are wooden bridges every few 100 meters :-)

 

So, my question to the community: Does someone has a solution or a workarround for this?

 

Thanks for your answers/replies in adavance and best regards,

 

FirstPanic

Share this post


Link to post
Share on other sites

I have a hacky solution where I just push the car with setVelocity. :D

If you make a trigger around the bridge and just force the car forward until it crosses then it usually works, although it sometimes doesn't look too pretty.

Share this post


Link to post
Share on other sites

OK... after a lot of investigation I think the only way is to "lead" the AI over the bridge by using a lot of  "setVelocity" into the right direction (probably every 0.1 second).

The challenges are:

  • What is the direction of the bridge?
  • Activation trigger needs to be on both sides of a bridge (cars can drive from both ends onto the brideg). Therefore the trigger needs to know if a car is driving to or from the bridge (no idea how to do that).
  • SetVelocity vector needs to have the correct length so that players will not see a difference in driving speed.

 

Not easy to do.... Anyone with ideas??

 

Regards,

Panic

Share this post


Link to post
Share on other sites
58 minutes ago, FirstPanic said:

OK... after a lot of investigation I think the only way is to "lead" the AI over the bridge by using a lot of  "setVelocity" into the right direction (probably every 0.1 second).

The challenges are:

  • What is the direction of the bridge?
  • Activation trigger needs to be on both sides of a bridge (cars can drive from both ends onto the brideg). Therefore the trigger needs to know if a car is driving to or from the bridge (no idea how to do that).
  • SetVelocity vector needs to have the correct length so that players will not see a difference in driving speed.

 

Not easy to do.... Anyone with ideas??

 

Regards,

Panic

Just push them forward (setVelocity second example) with one trigger.

The better solution would be to find the road positions, get dir and move them along the direction but it shouldn't be needed if they arrive at the bridge normally.

Share this post


Link to post
Share on other sites
1 hour ago, theend3r said:

Just push them forward (setVelocity second example) with one trigger.

The better solution would be to find the road positions, get dir and move them along the direction but it shouldn't be needed if they arrive at the bridge normally.

I think theend3r suggests the simplest solution to start with.   Start with a single bridge, and put a trigger on it  that is large enough to sense the vehicle before its bridge pathing AI goes wonky.  Then do a setvelocity loop on vehicle (using current velocity of vehicle when detected by trigger).  Direction of vehicle should  already be correct as it approached the bridge.  Make the duration of the loop a variable, so for longer bridges you can set a longer loop duration to get vehicle across the bridge.  Test AI driving across in both directions.

 

If that works good enough on one bridge, copy the trigger to other bridges and see what happens.  For longer bridges, increase the loop duration.

 

If that works pretty good and you're feeling really gung-ho, then think about it a map-wide solution where bridge objects are detected, triggers created per bridge (where size and direction of trigger calculated based on size and direction of bridge object), etc.

 

It totally sucks we have to spend time on this though, BI needs to fix it.  Is there a bug filed?  Has BI commented on it?

Share this post


Link to post
Share on other sites

OK... got it and wrote the following script which is very easy and is based on the BI Wiki example:

 

// Workarround to make AI driver over bridges 
// Sets the current velocity for a given time to a given vehicle
//
// Params:
//    _Vehicle = Vehcile to apply
//    _TimeInSeconds = duration in seconds to set the velocity of the vehicle 
//    _SpeedToAdd = Optional speed which will be added to the current velocity
//    _Direction = Direction to set the velocity
//
// Example:
//    [this, 2, 0, Direction this] execVM "Velocity.sqf";
//
if (!isServer) exitWith {};
Params ["_Vehicle", "_TimeInSeconds", "_SpeedToAdd", "_Dir"];
Private ["_Vel", "_i"];
hint str(_Dir);
_Vel = Velocity _Vehicle;
if (_SpeedToAdd <0 ) then { _SpeedToAdd = 0; };
if (_TimeInSeconds < 0) then {_TimeInSeconds = 0; };
for "_i" from 1 to (floor (_TimeInSeconds * 10)) do
{
    _Vehicle setVelocity [
        (_Vel select 0) + (sin _Dir * _SpeedToAdd), 
        (_Vel select 1) + (cos _Dir * _SpeedToAdd), 
        (_Vel select 2)
    ];
    sleep 0.1;
};

 

In adition I've placed a trigger in front of the bridge and set the direction of the trigger (which is available with the command TriggerArea) exactly to the direction of the bridge. Very easy to manage. In the activiation I wrote the following code:

_nul = [Jeep3, 2, 0, (TriggerArea BridgeTrigger1) select 2] execVM "scripts\Velocity.sqf";

What happens is nothing. Car is falling from bridge like always. I've checked the parameters and everything is right.

 

Any ideas, guys?

 

Thanks for replys

Panic

 

Share this post


Link to post
Share on other sites
2 hours ago, johnnyboy said:

I think theend3r suggests the simplest solution to start with.   Start with a single bridge, and put a trigger on it  that is large enough to sense the vehicle before its bridge pathing AI goes wonky.  Then do a setvelocity loop on vehicle (using current velocity of vehicle when detected by trigger).  Direction of vehicle should  already be correct as it approached the bridge.  Make the duration of the loop a variable, so for longer bridges you can set a longer loop duration to get vehicle across the bridge.  Test AI driving across in both directions.

 

If that works good enough on one bridge, copy the trigger to other bridges and see what happens.  For longer bridges, increase the loop duration.

 

If that works pretty good and you're feeling really gung-ho, then think about it a map-wide solution where bridge objects are detected, triggers created per bridge (where size and direction of trigger calculated based on size and direction of bridge object), etc.

 

It totally sucks we have to spend time on this though, BI needs to fix it.  Is there a bug filed?  Has BI commented on it?

Why set a duration? just make the trigger the size of the bridge and keep updating velocity while the vehicle is in the trigger area.

//trigger
//onAct:
inside = true;
_nul = [thislist select 0, 2] spawn {
	while {sleep 0.1; inside} do {
		params ["_vehicle", "_speed"];
		_vel = velocity _vehicle;
		_dir = direction _vehicle;
		_vehicle setVelocity [(_vel select 0) + (sin _dir * _speed),(_vel select 1) + (cos _dir * _speed),(_vel select 2)];
	}
}

//on deAct:
inside = false;

The above is obviously not the best solution as it produces very visible pushes but it's a good example as it's simple and allows the vehicle to turn somewhat. (A more procedural solution than using a global variable would be needed with some call compile format for a dynamic mission but that should be easy.)

  • Like 1

Share this post


Link to post
Share on other sites

Is the trigger firing?  Put this line in your script to confirm your trigger called the script, and confirm values of input variables:

hint format ["in script _Vehicle=%1, _TimeInSeconds=%2, _SpeedToAdd=%3, _Dir=%4", _Vehicle, _TimeInSeconds, _SpeedToAdd, _Dir]; 

 

Share this post


Link to post
Share on other sites

@theend3r's approach is valid as well.  As he pointed out his global variable is a potential problem.  If two different AI vehicles are crossing two different bridges at same time, these variables could cause problems.  Same if you have a convony crossing bridge where second vehicle enters trigger before first exits.  But it can be tweaked to work.

 

There is always more than one path up the mountain!  :)

Share this post


Link to post
Share on other sites

@Theend3r: Nice approach... like it... But it's not working. The car is doing a right turn after about 10-20 meter and is falling from bridge. I've added a "SetDir"... but no change... You can see that the AI is doing a right turn.

 

@johnnyboy: Yes... the trigger is firing. But as I said to Theend3r.... the AI is doing a right turn on the bridge.

 

Thanks for your comments... some good ideas in this discussion.

 

Regards

Panic

Share this post


Link to post
Share on other sites

Try adding disableAI "PATH" and disableAI "FSM" for the drivers.  If that doesn't work try enableSimulation False on the drivers to completely turn them off.

 

Its possible their AI is "steering", thus hosing the direction for setvelocity.  Once AI is turned off, setVelocity has to work, as the vehicle is just an object.  Sounds good in theory anyway!  Good luck hermano.

Share this post


Link to post
Share on other sites
19 hours ago, FirstPanic said:

@Theend3r: Nice approach... like it... But it's not working. The car is doing a right turn after about 10-20 meter and is falling from bridge. I've added a "SetDir"... but no change... You can see that the AI is doing a right turn.

 

@johnnyboy: Yes... the trigger is firing. But as I said to Theend3r.... the AI is doing a right turn on the bridge.

 

Thanks for your comments... some good ideas in this discussion.

 

Regards

Panic

What kinda bridges are we talking about here? I though most bringes are very short. If you want to force a vehicle over super long bridges then you need to get the positions of two bridge segments (and invert it according to the way the vehicle is going, i.e. the velocity vector of the vehicle) and force that dir (so no adding velocity but hard setting of velocity).

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×