Home   Help Search Login Register  

Author Topic: setpos question  (Read 1202 times)

0 Members and 1 Guest are viewing this topic.

Offline Blanco

  • Former Staff
  • ****
setpos question
« on: 06 Jan 2004, 22:28:40 »
What the code to place "unit1" one meters in front of "Unit2", facing eachother

It should also work when unit2 is watching N, S, E, W or what direction ever


I got

Quote
_dir = getdir unit2

Unit1 setpos [getpos unit2 select 0, (getpos unit2 select 1) + 1, 0]

unit1 setdir _dir - 180


But it doesn't work, it's a math question and I'm X3mly bad in math :D

something with cos & sin?  :-\

Prrlease help
« Last Edit: 06 Jan 2004, 23:16:29 by Blanco »
Search or search or search before you ask.

netta1234

  • Guest
Re:setpos question
« Reply #1 on: 07 Jan 2004, 13:17:03 »
i dont realy understand you

Offline Blanco

  • Former Staff
  • ****
Re:setpos question
« Reply #2 on: 07 Jan 2004, 20:05:52 »
ok, I try it again...

how can is setpos a unit1 one meter in front of unit2 and make them turn and look at each other, regardless what direction unit2 is facing?
Search or search or search before you ask.

junkie-xL

  • Guest
Re:setpos question
« Reply #3 on: 07 Jan 2004, 22:03:45 »
so you want to be able to setpos the player and have him facing another fellow, regardless of what particular position that other unit is occupying at that moment?

hmmm, couldn't you achieve this with
"player dowatch unit"

otherwise I think this needs to be calculated with some of the complex trigonometry you see applied in those very advanced scripts. so you need a formulate to calculate 180°. There's no such thing as setrelpos in setpossing I'm afraid. But I could be mistaken.

the "Demolition Diver" campaign you're working on looks very promising!

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:setpos question
« Reply #4 on: 07 Jan 2004, 22:57:28 »
Code: [Select]
#loop
?mortarsdead: exit
_bearing = random(360)
_distance = random(50)+40
?(local gl5): _shell = "mortarshell" createvehicle [(getpos (leader grp1) select 0) + sin (getdir (leader grp1) + _bearing) * _distance, (getpos (leader grp1) select 1) + cos (getdir (leader grp1) + _bearing) * _distance, 50]
?_shell distance mortar3 < 80: deletevehicle _shell; goto "loop"
_shell setvelocity [0,0,-50]
~random(3)+1
goto "loop"
Not all is lost.

Offline .pablo.

  • Former Staff
  • ****
  • When in doubt, empty the magazine.
Re:setpos question
« Reply #5 on: 08 Jan 2004, 00:57:49 »
Quote
Unit1 setpos [(getpos unit2 select 0) + (cos getdir unit2), (getpos unit2 select 1) + (sin getdir unit2), 0]

that should put him 1 meter in front of unit2, unless i messed something up

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:setpos question
« Reply #6 on: 12 Jan 2004, 04:57:36 »
Quote
I think this needs to be calculated with some of the complex trigonometry you see applied in those very advanced scripts. so you need a formulate to calculate 180°.

Code: [Select]
Unit1 setpos [(getpos unit2 select 0) + (cos getdir unit2), (getpos unit2 select 1) + (sin getdir unit2), 0]

Lol, it isn't really that complex... ::)

As far as the unit facing the other, try this:

Code: [Select]
_A setdir ((getpos _B select 0) - (getpos _A select 0)) atan2 ((getpos _B select 1) - (getpos _A select 1))
_B setdir ((getpos _A select 0) - (getpos _B select 0)) atan2 ((getpos _A select 1) - (getpos _B select 1))

I believe that is correct.....
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Blanco

  • Former Staff
  • ****
Re:setpos question
« Reply #7 on: 12 Jan 2004, 22:59:42 »
thx !

I found the dirtoobj.sqf in the function library, It's does the same no?

Search or search or search before you ask.