- Home /
Rigidbody momentum?
Hi, I have a character with a rigidbody that jumps forward using root transformation from the animation (basically, the jump animation moves the character forward).
This then leads to a secondary falling animation that plays whenever the rigidbody's Y velocity is < 0.
My problem here is that the character falls directly down, and I would like it to keep the momentum from the jump animations. On a similar fashion, if Im walking towrwards a ledge I would like to fall keeping that momentum too.
Any ideas what kind of code solution Im looking for? Im using C#, but Im more of an artist rather than a coder.
Answer by zharik86 · Oct 14, 2014 at 06:46 AM
At the very beginning of a jump add force in the direction necessary to you and the necessary value. If jump is forward:
public float fwdForce = 100.0f; //value of force for forward direction
public float upForce = 100.0f; //value of force for up direction
public Transform myCharacter = null; //reference at your character object
//Create simple function and use it by neccessary
public void myJump() {
myCharacter.rigidbody.AddForce((fwdForce*myCharacter.forward) + (upForce*Vector3.up));
}
Of course, you can to change value fwdForce and upForce, for more efficient. I hope that it will help you.
Need to experiment with this for a bit but looks like it may be the right approach. Thanks!
Your answer
Follow this Question
Related Questions
[Physics] Compensating for Moving/Rotating Terrain 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Parenting Preventing Player Rotation 0 Answers
Setting a component's values. 1 Answer