Home   Help Search Login Register  

Author Topic: getpos cont  (Read 1224 times)

0 Members and 1 Guest are viewing this topic.

Pow3r

  • Guest
getpos cont
« on: 29 Aug 2002, 19:41:33 »
This is what Sui wrote in reply to a guy's question on placing an object relevant to a unit's current position...


object setpos [(getpos unit select 0) + (sin (getdir unit - 90) * 20), (getpos unit select 1) + (cos (getdir unit - 90) * 20), 0]

Breaking it down to explain it...

(getpos unit select 0)

gets the x co-ord of unit

... + (sin (getdir unit - 90) * 20)

minus's a value that depends on the direction unit is facing. The - 90 means the position will be 90 degrees to the left of where the unit is facing. The * 20 means the distance will be 20m away.

... (getpos unit select 1) + (cos (getdir unit - 90) * 20)

this is exactly the same as the x co-ord line, apart from the underlined differences. These are necessary due to the y co-ord being perpendicular to the x co-ord


I could not get this to work for the life of me.  Instead of unit I put self... instead of unit I also tried the name of other soldiers... and instead of object I tried AAA317... just cuz I tried that object name once b4 with something else and seemed to work once.  I'm putting this in the init field of unit I try it on and doesn't work at all.  The guy that started the previous post about this said he had a solution and clicked solved but didn't say what had ended up working for him   >:(   I'd appreciate any help.  Basically, what I'm trying to do is place a tree or two or whatever in a map without having to go through the tediousness of scripting because I haven't learned all that is required for that yet.  Later, hopefully I'll learn the camcreate stuff. :)  Thanks in advance m8s.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:getpos cont
« Reply #1 on: 01 Sep 2002, 03:26:39 »
Look here. I posted a script that does this for you. All you ahve to do is just plug in the values.


http://www.ofpec.com/yabbse/index.php?board=8;action=display;threadid=840
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Demoniac

  • Guest
Re:getpos cont
« Reply #2 on: 07 Sep 2002, 01:12:27 »
Instead of getdir unit - 90 I would use (getdir unit + 270) % 360, this always gives you a value between 0 and 359.999999, so it's a little safety from possible errors...

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:getpos cont
« Reply #3 on: 07 Sep 2002, 06:39:45 »
Granted...

but sin 405 is the same as sin 045 anyway...
Just as sin -45 is the same as sin 315 ;)