OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Blanco on 01 Jul 2005, 19:27:21
-
Hello,
There are lots of small things in the editorupgrade like an ID card, a notebook, etc... I want to give someone one of these small objects
and when you kill that guy the object should be spawned and fall out of his pockets. Than I attach an action to the object so it can be picked up (virtually).
Lol, what am I saying?? The whole game is virtual :D
Whatever...
When I spawn an object at unit's position it appears in mid-air. What should I do to make it fall towards the ground respecting earth's graviation?
The easiest way please, because I'm not fond of that stuff... :-\
It shouldn't be perfect , cos you only see it in a blink of an eye anyway.
Is there a script or function for that?
-
Totally untested but try something like this:
_xcoord = getPos THING select 0
_ycoord = getPos THING select 1
_zcoord = getPos THING select 2
_newZ = _zcoord
_starttime = _time
#loop
~0.001
if (_newZ <= 0) then {exit}
_newZ = _zcoord - 9.8 * 0.5*(_starttime - _time)^2
THING setPos [_xcoord,_ycoord,_newZ]
goto"loop"Formula used is:
S=ut + 1/2 a*t^2
where u = 0
You might need to play around with the 9.8 and loop delay. As I said - completely untested.
-
S=ut + 1/2 a*t^2
sounds like something R2D2 might say... ;)
we are most lucky to have individuals such as you in our midst THobson.
as for the question - making it less than perfect - i'd suggest going to the other extreme and making it overly unrealistic so that it is a feature which the player can appreciate properly. try an elastic drop, maybe even let it bounce.
_x = getpos thing select 0
_y = getpos thing select 1
_z = getpos thing select 2
_d = 0
#loop
_z = _z - (1*sin(_d))
thing setpos [_x, _y, _z]
_d = _d + 0.1
?not (_z<=0):goto "loop"
exit
and where did i get the idea? why, from THobson of course :)
-
;) MMMMmmmm...Gravy...
Sorry. :P
-
why not just do a simple setvelocity [0,0,-9.8] ?
-
i don't think you can do setvelocity on a stationary object, only vehicles. that's why people do setpos loops, AFAIK.