OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Lean Bear on 03 Jan 2006, 15:57:33

Title: Getting the velocity of a unit
Post by: Lean Bear on 03 Jan 2006, 15:57:33
Just checking to see if it is possible to get the velocity of a unit (not in a vehicle) and return it in the usual array format [x,y,z] ?

So far, I've only been able to get it to work on vehicles...
Title: Re:Getting the velocity of a unit
Post by: bored_onion on 03 Jan 2006, 16:00:44
it might be the same as setvelocity which will indeed only work for vehicles. couldnt be sure though.
Title: Re:Getting the velocity of a unit
Post by: Igor Drukov on 03 Jan 2006, 16:02:43
This :

Code: [Select]
Hint format ["%1", velocity player]
...works like a charm :).
Title: Re:Getting the velocity of a unit
Post by: marcus3 on 03 Jan 2006, 18:11:47
i know u can get the velocty, but i dont think u can change it  :P
Title: Re:Getting the velocity of a unit
Post by: Terox on 03 Jan 2006, 20:01:03

Yes you can set velocity, but you have to do it locally
You cannot setvelocity a player unit, just objects

setvelocity [x,y,z]
Title: Re:Getting the velocity of a unit
Post by: Lean Bear on 03 Jan 2006, 21:27:16
@ Terox

So you're saying that you can't change the velocity of the player? (Or similar soldier unit?)
Title: Re:Getting the velocity of a unit
Post by: marcus3 on 04 Jan 2006, 02:57:10
i think u can, here, check this script out, it makes the unit 'Jump'
;      Script Copyright Rory Deutsch (Roni) May 2005 - rory@romad.com.au
;      Feel free to use, abuse or misuse as you see fit - just don't charge for it.

;      A script that allows a player to jump over low walls, onto roofs etc
;      Caution ! Jumping while sprinting may cause damage to player



;      Get jumper
_jumper = _this select 0

_startDamage = getDammage _jumper


;      If character is in the air or severely wounded then disable jump
? ((getPos _jumper) select 2) > 0.3 : exit
? _startDamage > 0.5 : exit





;      Place jumper off ground, give him a small upward velocity
_v = velocity _jumper

_vX = (_v select 0)
_vY = (_v select 1)
_vZ = (_v select 2) + 5

_jumper setPos [getPos _jumper select 0, getPos _jumper select 1, 0.3]
_jumper setVelocity [_vX, _vY, _vZ]


;      Move jumper to crouch position
_jumper playMove "CrouchToCombat"


;      If jumper injured while executing jump then force him prone
? getDammage _jumper > _startDamage : _jumper playMove "CrouchToLying"


hope thisa helps
Title: Re:Getting the velocity of a unit
Post by: Fragorl on 04 Jan 2006, 04:27:16
Yep, as Marcus has pointed out, you can set the velocity of a unit, but you have to setpos it off the ground slightly before you do. I guess it sticks, or something ;)
Title: Re:Getting the velocity of a unit
Post by: Lean Bear on 04 Jan 2006, 12:22:31
Very strange, well, if it works.. :)

Thanks for your help guys!