I have a GameObject
that can move freely around a sphere in any direction, and it is controlled by an on-screen virtual joystick. The GameObject
is manipulated using the Transform
component (does not have Rigidbody
attached).
I am trying to get the GameObject
to decelerate in it’s current moving direction if the direction is flipped. So say it is traveling around the sphere in one direction and then the joystick is flipped to the other side, right now the GameObject
just instantly starts going the other way. I want it to decelerate in the current direction until it’s speed equals zero, then start accelerating in the direction that the joystick is now pointing. Does that make sense? If not let me know and I can elaborate on that a bit. If you need any of my current setup, feel free to ask.
Edit:
Here is a high level look at my code (I’m not on my dev machine at the moment):
if (MoveJoystick.IsFingerDown() && Speed < MaxSpeed)
{
// Accelerate in current joystick direction until max speed is reached
}
else if (MoveJoystick.IsFingerDown() == false && Speed > 0)
{
// Slowly decrease speed until speed equals 0
}
// Move ship based on current joystick direction and speed
MoveShip();