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!