Jump to content
Sign in to follow this  
L!nk07

Setpos not working!!

Recommended Posts

I've tried everyting... Can someone please help me. I'm making a "place and build" building script. When I place the object, it moves the object north(sometimes little east). I have no idea why this is happening. The local object is deleted but it won't make a difference because I set the position after I created it. This must be a bug.

Here is my code:

P.S. Its .sqf scripting and I am quite new to this so maybe the problems lies there.

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

_obj = "MASH" createVehicleLocal [0,0,0];

_obj setdir (getdir player);

build = player addaction ["Build","build.sqs"]; //this just makes place = false

cancelaction = player addaction ["Cancel","cancel.sqs"]; //this just makes cancel = true

place = true;

cancel = false;

while {place && !(cancel)} do

{

_dir = (getdir player);

sleep 0.01;

_obj setpos [(getpos player select 0)+(_dist*(sin _dir)),(getpos player select 1)+(_dist*(cos _dir)),0];

_obj setdir _dir;

};

if (!(cancel)) then

{

_obj2 = "MASH" createVehicle [0,0,0];

sleep 0.1;

_obj2 setpos [(getpos player select 0)+(sin(getdir player)*10),(getpos player select 1)+(cos(getdir player)*10),(getpos player select 2)];;

_obj2 setdir (getdir player);

};

I have tried assigning the positions to variables but not helping and also tried to just add the values to place the object where it belonged but I couldn't find the pattern.

Maybe I can make just one object and stop updating the position when place = true. But that won't be multiplayer compatible (I think). Maybe there is away around that.

Please help...

Thx in advance,

L!nk

Share this post


Link to post
Share on other sites

Try using setDir before setPos in the _obj2 part of the script, it seems to resolve the issue.

Share this post


Link to post
Share on other sites

Jip, that works. Thank you very much.

I wonder why that happens but it works. Sometimes the answer is right in front of me but I just can't get it.

Thx again,

L!nk

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  

×