OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started 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
-
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.
-
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.
-
ok thanx guys ill give them both a shot :)
-
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....
-
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 ??? >:(
-
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.
-
the X,Y,Z cohordinates are absolute, non relative to the place you put
your MG in the editor.
That is, use:
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:
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.
-
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.
-
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.
-
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
-
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?
-
Yes. But it doesn't matter.
-
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 )
-
ok, makes sense. ;)