Home   Help Search Login Register  

Author Topic: Earth's graviation and objects  (Read 1044 times)

0 Members and 1 Guest are viewing this topic.

Offline Blanco

  • Former Staff
  • ****
Earth's graviation and objects
« 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?



« Last Edit: 01 Jul 2005, 23:32:43 by Blanco »
Search or search or search before you ask.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Earth's graviation and objects
« Reply #1 on: 01 Jul 2005, 19:36:23 »
Totally untested but try something like this:

Code: [Select]
_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.

« Last Edit: 02 Jul 2005, 01:26:43 by THobson »

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Earth's graviation and objects
« Reply #2 on: 01 Jul 2005, 20:20:33 »
Quote
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.

Code: [Select]
_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 :)

Crassus

  • Guest
Re:Earth's graviation and objects
« Reply #3 on: 05 Jul 2005, 17:14:51 »
 ;) MMMMmmmm...Gravy...

Sorry.  :P

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Earth's graviation and objects
« Reply #4 on: 06 Jul 2005, 04:10:58 »
why not just do a simple setvelocity [0,0,-9.8] ?

Offline Morglor9

  • Members
  • *
Re:Earth's graviation and objects
« Reply #5 on: 06 Jul 2005, 04:36:27 »
i don't think you can do setvelocity on a stationary object, only vehicles. that's why people do setpos loops, AFAIK.
Cymbaline