- Home /
Question by
DJPC3 · Oct 03, 2020 at 05:02 PM ·
2d game2d-physics
How can I gradually add force to my 2D player?
I want my 2D player, as he runs to gradually increase from his initial speed to a max speed.
Here's the movement part of my CharacterController script if you need more details please let me know:
// Move the character by finding the target velocity
Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody2D.velocity.y);
m_Rigidbody2D.AddForce(targetVelocity);
// And then smoothing it out and applying it to the character
m_Rigidbody2D.velocity = Vector3.SmoothDamp(m_Rigidbody2D.velocity,
targetVelocity, ref m_Velocity, m_MovementSmoothing);
Comment
Your answer
Follow this Question
Related Questions
2D random shooting problem with velocity, 0 Answers
Stacked Bullets on Instantiation 0 Answers
2D collision matrix does not work in unity 2020 4 Answers
My ground checker only works... sometimes 1 Answer
Having some stuck issues on the 2D infinite runner 0 Answers