Difference between revisions of "Talk:SetVelocity"
Jump to navigation
Jump to search
no edit summary
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 ...") |
imported>Mitchalek |
||
Line 5: | Line 5: | ||
Trigonometry is a must and calculating movement vectors with | Trigonometry is a must and calculating movement vectors with sin and cos: | ||
<i>Set | <i>Set cos to (source.GetPos x - target.GetPos x) / source.GetDistance target | ||
Set | Set sin to (source.GetPos y - target.GetPos y) / source.GetDistance target</i> | ||
Then multiply desired velocity on | 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: | 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: |