Jump to content
Sign in to follow this  
Taurus

Truck/Car doMove position

Recommended Posts

Searched for:

distance and stops and truck and short

didn't return anything

distance and stops

didn't return anything of use

distance and doMove

didn't either

distance

returned 6 pages of, well nothing of use...

So here goes..

Having

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_vehicle = _this //either a truck or a car

_position = getMarkerPos "myMarker";

_vehicle doMove _position;

//Having that speed doesn't return proper values sometimes, and velocity should be used instead...

while{speed _vehicle > 0} do{

sleep 0.5;

};

//Vehicle has stopped at its destination.

player sideChat format["Distance to marker: %1",_vehicle distance _position];

Player will say

Distance to marker: 7.89192

It seems vehicles stop 7-9 meters short of their intended destinations.

Why?

Is there a way to be able to move them closer, lets say less than 1 meter of the marker pos?

meh, if board would display "edited post" it would be

MyCurrentPosts * 304131512222

[edit]

I did some additional tests

Man

moves to a WP

WP distance when stopped: 0

doMove to a GameLogic

GL distance when stopped: ~0,6

doMove to a Marker

Mrk distance when stopped: ~0,8

Humw

moves to a WP

WP distance when stopped: ~0,2

doMove to a GameLogic

GL distance when stopped: ~6,5

doMove to a Marker

Mrk distance when stopped: ~6,4

Truck

moves to a WP

WP distance when stopped: ~1,7

doMove to a GameLogic

GL distance when stopped: ~7,7

doMove to a Marker

Mrk distance when stopped: ~7,2

Tank(Abrams and M113)

moves to a WP

WP distance when stopped: 0

doMove to a GameLogic

GL distance when stopped: ~5,19

doMove to a Marker

Mrk distance when stopped: ~4,82

Share this post


Link to post
Share on other sites

I noticed the choppers do the same except its about 100 meters distance.

I havent tried it yet but you could try a trick I was thinking of.

Basically you set a second domove beyond the actuall position at the correct angle of approach.

something like :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_markpos = getmarkerpos "Marker"

truck domove _markpos

_dst = truck distance _markpos

@ _dst < 10

;create a logic at the marker position

_lgc = "Logic" createvehicle _markpos

;this below code was borrowed from another forumn user whos name I forget but their code works great for getting dir to object.

_posa = getPos truck

_posb = getMarkerPos "Marker"

_dir = ((_posb select 0)-(_posa select 0)) atan2 ((_posb select 1)-(_posa select 1))

;start of my code

;set logic to direction of truck to marker

_Lgc setdir _dir

;create a cam and set it twenty meters ahead on the logics bearing

_cam2="Camera" camcreate [0,0,0]

_cam2 camsettarget _Lgc

_cam2 camsetrelpos [0,20,0]

_cam2 camcommit 0

;set the logic to the new cams position

_lgc setpos getpos _cam2

camdestroy _cam2

;send the truck to the new position so it will keep going towards original goal.

truck domove getpos _lgc

_dst = truck distance _Markpos

@ _dst < 1: hint "truck has arrived"

dostop truck

deletevehicle _lgc

So you have tricked the unit to go beyond the actuall position and then you can dostop the unit when it arrives.

With this code the truck should drive directly over the original target position but you may need to change the thresholds a bit. Like setting the distance for the trick position to 30 meters.

I hope this same technique will make my choppers go faster through their waypoints. It looks silly watching the chopper stop allong the way instead of charging ahead like it should..

Share this post


Link to post
Share on other sites

TJ72

Kool!

I'll play around with that.

I noticed a VERY, well not interesting, but annoying thing.

Trucks(and probably all vehicles)

REFUSES to move distances less than 10 meters.

I mean, why spend fuel on moving less than 10 meters when they constantly have their engine running...

Put yourself as a leader of a Truck.

Try to command(move) him to a position 5 meters in front of you

2: Waiting

Try to command him 10 meters away

2: Waiting

Now try 11 meters

Wrroooom

2: Waiting...

And thats probably why they settle on stopping at ranges 8 - 10 meters away from the position.

For Choppers it seems to be ranges over 100 meters where they accept to fly to.

All less than 100

2: Ready,Waiting.

I will try to see what happens with choppers doMove.

So I guess for your choppers to fly past the WPs without stopping

(.sqs would be?)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

@(_chopper distance _pos) <110

_chopper doMove _myOtherPos

.sqf is

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

waitUntil{(_chopper distance _pos) <110};

_chopper doMove _myOtherPos;

[edit]

About them choppers

Yes, it seems they settles with stopping 100m + from the position.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_chopper doMove _pos;

//less than 2, 0 doesn't work,,,)

waitUntil{speed _chopper < 2};

player sideChat format["Distance:%1",_chopper distance _pos];

"Player:Distance 101.01243"

[edit2]

However, they ARE fanatical about waypoints, where they rather run out of fuel or get shot down unless they are 0 meters from the WP center.

Share this post


Link to post
Share on other sites

Class man:

precision = 1;

Class car:

precision = 10;

Class truck:

Class car value

Class Plane:

precision = 200;

class Helicopter:

Class Air value

class Air:

precision = 100;

All from the main config.bin. smile_o.gif

You could lower these, but lower then 1 isnt advised. (WP may never be reached), and the AI may get in trouble with the pathfinding.

Share this post


Link to post
Share on other sites

banghead.gif

:cry:

5 hrs of experimenting and testing something that can be read from a file sad_o.gif

But thanks for enlighten me wink_o.gif

Well, it didn't come out too bad,

TJ72 provided me with a script which I can use, and I made another version of it without using the camCreate thingy.

Case close I suppose!

[edit]

WOOT my 500:th post OMG!

yay.gif

Share this post


Link to post
Share on other sites

In case of moving land vehicles to exact spot, it depends on what do you want exactly, but ordering them to move to the exact position of a road object was helping in OFP.

I used this in my BUS traffic scripts, when the BUS was supposed to arrive at a BUS station and was unable to get in the right position (they allways tend to stop few meters before the station).

And i solved it by ordering the buses to move to the position of the road object nearest to the station.

...its most probably useles in this case, but maybe someone can benefit from this when solving similar problem.

Share this post


Link to post
Share on other sites

Case reopened smile_o.gif

This could help me as my trucks are traveling down roads.

5133p39

What kind of object?

The bus-stop building itself, or what road object?

Share this post


Link to post
Share on other sites
What kind of object?

The bus-stop building itself, or what road object?

The road itself - the road is composed from things i call "road objects" - the asphalt thing you see on the ground, its an object - it does even have its own Object ID.

Open the mission editor, set the object id to show, and zoom in at some road.

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
Sign in to follow this  

×