Advertisement

Author Topic: Attach unit to player - I'm going crazy here  (Read 404 times)

0 Members and 1 Guest are viewing this topic.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Attach unit to player - I'm going crazy here
« on: 02 Mar 2008, 19:10:54 »
Hi all.

I'm working on a script where I want a unit (soldier) to be attached (through setpos command) to the player, but any possibile way I try to solve this issue the attached soldier allways stays on ground level.
If I walk into a building or on top of a terrace structure, the unit is still attached to the player but his level above ground doesn't change as the players does. The player can be on top of a ten floor building and the attached soldier is sliding around down on the street. Meaning : not looking good and makes my idea useless if I can't solve it. I have tried it with normal setpos getpos commands which didn't work, then I tried it like this and it still doesn't work. Not even in the editor.

Here is my script. Please help, Iv'e been trying to solve this and looked for information all day. Sigh

#startofscript#

letgo = player addaction ["Drop Wounded Soldier", "letgo.sqs"]
dropping = false
PublicVariable "dropping"

#loop

_carrierpos = [getposASL player select 0, getposASL player select 1, getposASL player select 2]
? dropping : player removeaction letgo; exit
? velocity player select 0 > 5 OR velocity player select 1 > 5 : dropping = true; PublicVariable "dropping"; exit
? ! (alive player) : wounded setposASL [getposASL wounded select 0, getposASL wounded select 1, getposASL wounded select 2]; dropping = true; PublicVariable "dropping"; exit

wounded setdir getdir player
wounded setposASL _carrierpos

~ 0.01

goto "loop"

#endofscript#

Thanks in advance all of you oracles.

Cheers

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Attach unit to player - I'm going crazy here
« Reply #1 on: 03 Mar 2008, 13:24:01 »
You may try using modelToWorld coords and see what happens inside buildings:

Code: [Select]
wounded setpos (player modelToWorld [0,0,0]); instead of
Code: [Select]
wounded setposASL _carrierpos

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Attach unit to player - I'm going crazy here
« Reply #2 on: 04 Mar 2008, 21:40:40 »
Million thanks Mandoble.

Works great, at least in editor.

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.