Talk:SetVelocity

From the Oblivion ConstructionSet Wiki
Revision as of 18:02, 13 August 2011 by imported>DragoonWraith (cool)
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 sin and cos:


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

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


Then multiply desired velocity on X with cos and Y with sin 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. ;)

Useful stuff; the game can be really inconsistent about its conversion from feet to units and back (sometimes it seems to use just 21, other times 21.3333 with some arbitrary number of threes that seems to vary from place to place). Glad that you've fiddled with this; I'm going to mention the gravity thing on the page.
You are, by the way, welcome to update the page itself with these kinds of findings. I do recommend taking a look at Help:Editing for some pointers, though; italics aren't the best choice for code.
Also, please sign your comments in Discussion pages by ending with ~~~~; that will insert your username and a timestamp. Thanks!
Dragoon Wraith TALK 19:02, 13 August 2011 (EDT)