I think in theory this should push the object along it’s forward vector by whatever drive_currentSpeed is set to.
But in reality I get strange behavior, the object is jittery and then sails upwards into the sky? (The object in question is a collision capsule, with rigid body and the script attached. So it’s middle point should be directly in the center of the object, from my understanding?)
Given an object’s rotation, and the this.entity.forward vector, how can I “push” the rigidbody with the correct impulse direction? I keep trying different formulas but end up either not moving the object at all, or having it spazz out into space.
A new issue with the above is that turning the object doesn’t actually change where it’s current velocity is going, only where it is being pushed from. This leads to a “sliding on ice” feeling to the movement. I actually solved that myself using this line instead:
Though it is certainly not a perfect solution, overwriting the linearVelocity directly seems to do the trick for now(force the object in the direction desired while still respecting walls in the way). I will need to figure out some code to handle bouncing off of walls and such, as the above rightfully gets the object “stuck” to any walls it hits. But collisions are a whole other topic entirely. You’ve gotten me off in the right direction, at least.
EDIT: LOL, I just discovered this new method of movement also eliminates the effect of gravity on the object. Now my character floats over all the wonderful holes I left for them to jump over. Figured I would mention that for anyone else trying the above.
Linear velocity is normally derived by the physics engine and you shouldn’t normally set it directly yourself. Exceptions are when you want to reset a body, or maybe if you want to cap a body’s linear velocity to some maximum (although as I mentioned before, you can do this with careful selection of damping and friction values).
I am late to the discussion, but moving the entity along the forward axis is really important in the game that I am developing currently. I am not quite following the discussion; it would really help if you could send the whole code.