Home   Help Search Login Register  

Author Topic: setPos inaccuracy  (Read 2017 times)

0 Members and 1 Guest are viewing this topic.

sussmori

  • Guest
setPos inaccuracy
« on: 24 Aug 2002, 06:52:33 »
Hi,

Normally i'd look through the old posts in the forum for this, but since they aren't up yet...

When I use _fence setPos (getPos _fence) to modify the height of an object, it moves slightly right/left. How do I get around this?

thx

tai mai shu

  • Guest
Re:setPos inaccuracy
« Reply #1 on: 24 Aug 2002, 10:23:04 »
your using a redundant syntax...

put this in the init field of the fence object: this setpos [(getpos this select 0), (getpos this select 1), (getpos this select 2) + heightyouwant

sussmori

  • Guest
Re:setPos inaccuracy
« Reply #2 on: 24 Aug 2002, 12:27:05 »
Yer that's what i mean. But this syntax still moves the object right/left slightly

Rubble_Maker

  • Guest
Re:setPos inaccuracy
« Reply #3 on: 24 Aug 2002, 12:40:57 »
Oh I know exactly what you mean ;)

When I wanted to make fence doors which the player can open for my SPM "The Prey", I had to offset each x,y coord by a certain amount (which I figured out by simple try&error).

The good news is that its possible to cancel out the inaccurancy, but it requires a lot of trying.

The bad news is that the offset is different depending on the map heading and position of the object, so you'll have to go thru that pain for each fence door you use.

Tactician

  • Guest
Re:setPos inaccuracy
« Reply #4 on: 24 Aug 2002, 15:00:32 »
I'm thinking part of the problem is the inaccuracy of getPos.  If it doesn't get the numbers precisely enough, maybe OFP just makes up the next few digits?  Anytime you create an object using getPos, it will vary in position.  This is true of createVehicle, createUnit, et cetera.  Try using getPos and a radio trigger to show the coordinates, write them down, and use those coordinates in the init field except adding extras zeros after the decimal.  See if that makes anything more precise.  With a simple script, you could automate that.

_posx = getPos object select 0
_posy = getPos object select 1
_alt = getPos object select 2
_posx = _posx + .0000000000000000000000001
_posy = _posy + .0000000000000000000000001
object setpos [_posx, _posy, _alt]

Does that make sense, or should I lay down the crackpipe?  I haven't read any studies on number precision in Flashpoint, but if you have please enlighten me.

vektorboson

  • Guest
Re:setPos inaccuracy
« Reply #5 on: 24 Aug 2002, 19:43:11 »
This must be a bug! If you move an object by setPos it always will go sideways, but if you move a vehicle, it won't!

I made following workaround: I have a logic, where I want the object to be, then I do:

MyObject setpos (getpos LogicName)

The same happens to setDir getDir! The object not only changes its direction but it moves slightly away from its position! So you take again a logic, set its direction, then

MyObject setDir (getDir LogicName)

Gameer_77

  • Guest
Re:setPos inaccuracy
« Reply #6 on: 24 Aug 2002, 21:23:55 »
Jeez, theres a lot of llama's on this forum, isnt there?  ;)

 8)PEACE
« Last Edit: 24 Aug 2002, 21:24:44 by Gameer_77 »

Offline Gastovski

  • Members
  • *
  • #loop; Gastovski setdammage 0; ~0.01; goto "loop";
    • Falklands Mod
Re:setPos inaccuracy
« Reply #7 on: 24 Aug 2002, 21:46:24 »
Yeah i didn't know I was a llama until I came here!!!

And the getpos/setpos commands are not very accurate (check the tutorials when they come back up)

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Solution for Yall'
« Reply #8 on: 29 Aug 2002, 00:54:39 »
I ran into this but there is an easy way around it. The problem is the inaccuracy of getpos, NOT the inaccuracy of setpos.

Say you want to do the gate thing, where you setpos it to make it appear to be opening and closing.

Place your gate and in your init.sqs file do a command like this:
gate1pos = getpos gate1
gate1 setpos gatepos


You will notice that the gate will move a bit to the side because of the intial setpos in the init.sqs. This is fine...it wont happen again beucase its the only time you use getpos on the gate.

Now for "gate1", you have a starting position that will never change because of the inaccurate getpos command.

Now, to make you gate go down you can do something like this....

gate1 setpos [gate1pos select 0,gate1pos select 1, ((gate1pos select 2) - 0.2)]

By only using the position you got at the beggining and not using the inaccurate getpos over and over again, your gate will allways stay "in line".

"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.