Talk:SetVelocity

From the Oblivion ConstructionSet Wiki
Revision as of 14:06, 12 August 2011 by imported>Mitchalek (Created page with "Velocity has to be applied every frame in order to work. I ran into a few problems trying to move Idle NPCs. It seems impossible to overcome the initial friction but moving them ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Velocity has to be applied every frame in order to work. I ran into a few problems trying to move Idle NPCs. It seems impossible to overcome the initial friction but moving them few units higher above where they are standing before trying to apply velocity should do the trick:


target.MoveTo target 0 0 5


Trigonometry is a must and calculating movement vectors with sine on X and Y axis:


Set sineX to (source.GetPos x - target.GetPos x) / source.GetDistance target

Set sineY to (source.GetPos y - target.GetPos y) / source.GetDistance target


Then multiply desired velocity on each X and Y with sine values to get target move from/to the source.

Another problem I ran into was that game seems to apply gravity before velocity so I had to find a constant value that I would apply to Z axis in order to negate initial gravity or target would fall to the ground and cease to move because of the friction. I did some testing there using GetLocalGravity and value was something like -515. I tried experimenting with different Z velocities values until I reach antiG state and I found a sweet spot around 24 and I came to a conclusion that its actually gravity which is expressed in game units converted to feet by multiplying with (21+1/3). So in order to get that antiG constant use:


Set antiG to GetLocalGravity Z / (21+1/3) * -1


I hope it helps. ;)