Jump to content
Sign in to follow this  
kuwahara<ANZAC>

Setpos Getpos on objects help!!

Recommended Posts

ok the problem i have is when i setpos getpos for an object..

the icon moves on the map and acts like the object is moved but it is invisable.. the 3dmodel is missing..

this is no problem for OBJECT1 as it is an invisable H..

but object 2 is a tent and the map says it there but i dont see it??

can someone help me with making OBJECT2 move so i can see its model.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

MARKER1=true

titletext ["Click on the map to set position.","plain down"]

onMapSingleClick "OBJECT1 setpos _pos;MARKER1=false"

@!MARKER1

"MARKER1" setmarkerpos getpos OBJECT1

"Marker2" setmarkerpos getpos OBJECT1

"Marker3" setmarkerpos getpos OBJECT1

OBJECT2 SetPos GetPos OBJECT1

~0.5

playsound "SOUND1"

~1

"MARKER1" setmarkerpos [0,0]

onMapSingleClick ""

titletext ["","plain down"]

exit

Share this post


Link to post
Share on other sites

I.. don't understand? Your post makes it sound as though you want to make the H's move to the tent's position?

The script looks like it's loosely based on Mr-Murray's artillery script, am I correct?

My advice is to try contacting Mr-Murray and ask if you can modify his artillery script to suit your purposes - it'll be quite easy, as all his artillery script does, in essence, is create a bomb at the selected grid coordinate, and blow it up.

Edit: Sorry, misread your post. It's 00:52 GMT, and I'm knackered. You're saying that you can't see the tent when it's moved, yes? A few things here.

First off, I can't see that you've declared the variable '_pos'. The script seems to be just telling ArmA there's a variable there, but not what it actually is. Again, try looking closely at Mr-Murray's artillery script, as this is a good example of.. heck, he uses exactly the same methods...

Secondly, if you've moved object one to the map point with 'onMapSingleClick', it's probably easier to just create a tent there rather than simply move one to that point. That way, if the tent's destroyed a new one can be called in future.

Finally, I'm sure the '3d model' isn't missing - ArmA can't figure out what the heck '_pos' is because you haven't told it yet, so OBJECT2 - the tent - isn't moving anywhere. Because ArmA doesn't give an error message if a variable isn't found, ArmA isn't saying "Dude, who or what is _pos?".

Like I said, check out Mr-Murray's artillery script for an excellent hint at how to solve your problem. Don't steal his work, and give full credit to him.

Good luck, happy editing.

Share this post


Link to post
Share on other sites

Are you using it in a singleplayer or multiplayer mission? There are some (apparently intentional) syncronization problems with setPos on static objects in MP.

Somerville, no, _pos is actually a reserved variable when used in the onMapSingleClick command, it is automatically defined as the position that was clicked on the map.

Share this post


Link to post
Share on other sites

ok the script is working fine and i can see the tent is moved on the map and if i move something to the objects position IT IS THERE. but the game isnt rendering theobject visable to see in game..

look at the map and the icon for the object is there just not visable in game!!

is there a way for me to send the x,y,z of the click to the script and use it to set the position of the object??

it is to use in a MP mission but the exact same problem is there in preview from editor.

iv found some info on modelInWorld but i think thats an OFP command.

Share this post


Link to post
Share on other sites
/bump cos i really need help with this.

Sorry but it's seemingly unexplainable, I've never seen anything like this happen.

Share this post


Link to post
Share on other sites

try this

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">MARKER1=true

titletext ["Click on the map to set position.","plain down"]

onMapSingleClick "OBJECT1 setpos _pos;MARKER1=false"

@!MARKER1

"MARKER1" setmarkerpos getpos OBJECT1

"Marker2" setmarkerpos getpos OBJECT1

"Marker3" setmarkerpos getpos OBJECT1

;OBJECT2 SetPos GetPos OBJECT1

_relpos = [0,0,12.6]

_worldpos = object1 modeltoworld _relpos

object1 setpos _worldpos

object2 setpos _worldpos

_x = (getpos object1 select 0)

_y = (getpos object1 select 1)

_z = (getpos object1 select 2)

hint format ["%1 %2 %3",_z,_y,_z]

~0.5

;playsound "SOUND1"

~1

"MARKER1" setmarkerpos [0,0,0]

onMapSingleClick ""

titletext ["","plain down"]

exit

I left some test script in so you can see whats happening with height etc.

but basicly your _pos is 13 meter below ground and consequently so is your tent.

no promise for mp, like other said static object setpos and mp where not compatible before 1.05 .so good luck.

Share this post


Link to post
Share on other sites

this is awsome and worksvery well, but has a static hight on the object.

ATM it sets the object to 12.6 meters high on any terrain.

so if place it on a beach it is 12m off the ground and if i try place it 30m up a mountain it is underground..

is there a way to get the ground hight from the map click and pass it onto the object placment hieght??

Share this post


Link to post
Share on other sites

i am not aware of the reason behind _pos being at a minus height.

try _relpos [0,0,0]

its all freaky to me. and this will be your ultimate solution to get a propper _pos

you can try

_x = (_pos select 0)

_y = (_pos select 1)

_z = (_pos select 2)

_object 2 septos [_x,_y,0]

arma is asleep now ,i shall try tomorrow if its not solved.

the only other thing i can think of is trying to work distance between marker and object

_dis = marker1 distance object1

_relpos = [0,0,_dis]

try to replace this line _relpos = [0,0,12.6]

with the 2 lines above.it will only work if marker has retained a height of 0

best thing maybe swap one of your marker for a game logic, iirc they always at land level or was it empty detector ?

you also have asl and things.

anyway good luck

~8hours

resume

Share this post


Link to post
Share on other sites

SOLVED

this is setup as a respawn point mover that takes an object with it.

as its set right now it will move 3 markers and 2 objects.

1 marker and 1 object are part of the script so it really moves 2 markers and 1 object to the location clicked on the map.

MARKERS>

setfireA = marker for script,moves out of way after map click

medic_base1 = marker, used for map marking of spawn for players to see on map in mission.(editable)

respawn_west = marker, respawn point for players.(editable)

OBJECTS>

BTarget = object for script, this must be a game logic!!

medictent1 = object, this object can be anything you want at the respawn point.. mine is a field hospital with an ammo cache inside it.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_x = (_pos select 0)

_y = (_pos select 1)

_z = (_pos select 2)

setfireA=true

titletext ["Click on the map to set position.","plain down"]

onMapSingleClick "BTarget setpos _pos;setfireA=false"

@!setfireA

"setfireA" setmarkerpos getpos BTarget

"medic_base1" setmarkerpos getpos BTarget

"respawn_west" setmarkerpos getpos BTarget

medictent1 setpos [ getPos BTarget select 0, getPos BTarget select 1, 0]

hint "Respawn Point Set"

~0.5

playsound "RADIOCRACK"

~1

"setfireA" setmarkerpos [0,0,0]

onMapSingleClick ""

titletext ["","plain down"]

exit

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×