Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

rigidbody2D with instant max speed and slow stop

$
0
0
I've been trying to achieve this for longer than I care to admit... Here is my current code: public float maxSpeed = 10f; private Vector2 movement; void Update () { float x_move = LeftJoystick.position.x; float y_move = LeftJoystick.position.y; movement = new Vector2 (x_move * maxSpeed, y_move * maxSpeed); } void FixedUpdate() { rigidbody2D.velocity = movement; } Using "rigidbody2D.AddForce(movement)" creates an ice skating effect... I want the character to be able to hit instant top speed and then when I let off the joystick have him slow to a stop. But also be able to instantly change direction when the joystick is pressed again. Please help!

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>