OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: CopyrightPhilly on 14 Jun 2005, 00:53:53
-
ok chaps, i'v read the tut on this but i still cant get it to work how i want...
first off heres the code i have...
_unit = player
_d = (getdir _unit - 270)
_x = (getpos _unit select 0) - (7.8 * cos _d)
_y = (getpos _unit select 1) + (7.8 * sin _d)
_main = "FenceWood" createvehicle [_x,_y,0]
_main setdir ((getdir _unit) + 90)
_main setpos [_x,_y,0]
_d = (getdir _main)
_x = (getpos _main select 0) + (2.4 * sin _d)
_y = (getpos _main select 1) - (2.4 * cos _d)
_wall = "FenceWood" createvehicle [_x,_y,0]
_wall setdir _d
_wall setpos [_x,_y,0]
exit
Now what i want it to do
Place a sandbag wall (fencewood) infront of the player (which works fine) and then place another right next to the one it just made.
Now i want this to work no mater what direction the user is facing, but if u test it you will see it dosnt make the second one right next to the first.
any ideas?
cheers,
Phil
-
ok my maths sucks but i learned somthing today anyways...
sin (Sine) is always the y axis
cos (Cosine) is always the x axis
so...
how would i make somthing move to the left/right?
edit:
well it only took me just under 4 hours to work out, but hey at least my maths is a little better now :o
i took away 90 from the directed of the first fence made and then added it again when moving the second into place so it all lined up just nice...
so heres what i ended up with
_d = (getdir _unit - 270)
_x = (getpos _unit select 0) - (7.8 * cos _d)
_y = (getpos _unit select 1) + (7.8 * sin _d)
_main = "FenceWood" createvehicle [_x,_y,0]
_main setdir ((getdir _unit) + 90)
_main setpos [_x,_y,0]
_d = (getdir _main - 90)
_x = (getpos _main select 0) - (2.4 * cos _d)
_y = (getpos _main select 1) + (2.4 * sin _d)
_wall = "FenceWood" createvehicle [0,0,0]
_wall setdir _d + 90
_wall setpos [_x,_y,0]