OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Goatcheese on 02 May 2005, 12:27:35

Title: Setunitpos???? (newbie question)
Post by: Goatcheese on 02 May 2005, 12:27:35
hey all....im a newbie with a question.....ive got some machine guns in a bunker but they are appearing through the fllor and arent high enough to shoot out the window of the bunker.......ive read that u can set a units hieght and i was wondering if it would help me?........plz help ive got a really good mission in mind......thanx
Title: Re:Setunitpos???? (newbie question)
Post by: macguba on 02 May 2005, 14:08:42
You need a setPos command.   Look it up in the online command reference, which has an example of the kind of thng you need.

Depending on the exact nature of the bunker it may not work but give it a try.   Set the MG a little above where you want and see if it drops correctly onto the floor.
Title: Re:Setunitpos???? (newbie question)
Post by: THobson on 02 May 2005, 16:41:50
You should also look at buildingPos.  I don't know if any are defined for a fortress, but if there are any they are likely to be in some very useful places.
Title: Re:Setunitpos???? (newbie question)
Post by: Goatcheese on 03 May 2005, 09:35:54
ok thanx guys ill give them both a shot  :)
Title: Re:Setunitpos???? (newbie question)
Post by: Goatcheese on 03 May 2005, 09:57:00
ok well i found out how to do the set pos but i cant get the unit to stay in the same place.......im using    unitname setPos [X,Y,Z]       if i add something to the X and Y areas it ends up sending my unit miles away from where hes meant to be. If i just add something to the Z area and hav X and Y = 0......then my unit doesnt rise any higher off the ground.....im in a really difficult problem.....any ideas would help....
Title: Re:Setunitpos???? (newbie question)
Post by: Goatcheese on 03 May 2005, 11:43:09
oh and another piece of info.......if i set the X and Y stats to zero then my unit starts over the ocean somewhere....can anyone help me??........i dont understand how i get my unit to stay where i placed it but raise it up a little bit ??? >:(
Title: Re:Setunitpos???? (newbie question)
Post by: macguba on 03 May 2005, 12:02:42
X is east-west
Y is north-south
Z is up-down

The origin of the map [0,0,0] is sea level in the bottom left hand corner.

Try it on a flat piece of grass somewhere.   The fortress is probably screwing things up.

When you encounter a new command, it is usually worth making it work in a very simple situation first, before trying it in a live mission.

IIRC loons are subject to gravity but objects are  not.
Title: Re:Setunitpos???? (newbie question)
Post by: sa8gecko on 03 May 2005, 12:03:38
the X,Y,Z cohordinates are absolute, non relative to the place you put
your MG in the editor.
That is, use:
Code: [Select]
unitname setpos [getpos (unitname) select 0,getpos (unitname) select 1, Z]Z is tricky to determine, cause setpos use ABSOLUTE rather than RELATIVE
heights above ground: that is, height above sea level is required.
To determine this Z, just place a gamelogic under the X,Y cohordinnates of
the unit at height 0 and then take the distance from the unit itself, and add
to this the height you want the unit to be raised above ground:
Code: [Select]
logic = "gameLogic" camcreate [0,0,0];
logic setpos [getpos (unitname) select 0,getpos (unitname) select 1, 0];
dist = logic distance unitname;
unitname setpos [getpos (unitname) select 0,getpos (unitname) select 1, dist + height]
where height is the height above ground you want unitname to be.

EDIT>
Macguba already answered part of this in the post above.
Title: Re:Setunitpos???? (newbie question)
Post by: macguba on 03 May 2005, 12:06:35
Err, I thought z was the height above ground level, not sea level.    So to raise something 2m above its original spot you would use

this setPos [getPos this select 0, getPos this select 1, 2]

in its init field.
Title: Re:Setunitpos???? (newbie question)
Post by: sa8gecko on 03 May 2005, 12:39:43
Code: [Select]
Err, I thought z was the height above ground level, not sea levelI was confused by the fact that  'EmptyDetector' objects obey the ASL height  rule.
Title: Re:Setunitpos???? (newbie question)
Post by: Goatcheese on 04 May 2005, 07:50:29
thanx guys for ur help i got it to work ;D
oh yeh...thanx especially to sa8gecko ur code helped aot

once again thanx guys ;D ;D ;D
Title: Re:Setunitpos???? (newbie question)
Post by: Zombie on 04 May 2005, 21:52:57
hmmm interesting takes on the issue...my 2 cents:

this setpos [(getpos this select 0), (getpos this select 1), (getpos this select 2) + height above ground desired in meters]

Then I just put the object where I want in the editor......

am I doing too much typing?
Title: Re:Setunitpos???? (newbie question)
Post by: macguba on 04 May 2005, 22:07:33
Yes.   But it doesn't matter.
Title: Re:Setunitpos???? (newbie question)
Post by: THobson on 05 May 2005, 22:52:52
Lol  ;D
You only need the brackets when you are adding or subtracting a value.

so
getPos blob select 0,

is okay

getPos blob select 2 + 10

causes a bit of a problem because the + is resolved before the select so this is saying

getPos blob select 12

which is nonsense.

this setpos [getpos this select 0,getpos this select 1, (getpos this select 2) + height above ground desired in meters]

Works fine and saves you two ( and two )



Title: Re:Setunitpos???? (newbie question)
Post by: Zombie on 06 May 2005, 12:34:23
ok, makes sense.   ;)