- Home /
Slow Sprite Rotation Toward Movement Direction - Top-Down 2D Game
I have a projectile I want the player to control. I want the sprite that is the projectile to slowly rotate toward the movement direction the player is holding down. I can get it to snap to the direction, but that's jarring. Many other answers have a target, but I'd like this to be freeform movement without a specific target. Just controlled with the directional inputs. Any ideas?
private void Update()
{
horizontal = Input.GetAxisRaw("Horizontal");
vertical = Input.GetAxisRaw("Vertical");
move = new Vector2(horizontal, vertical);
if (Input.GetKey(KeyCode.LeftShift))
{
playerControlling = true;
if (move.x != 0 || move.y != 0)
{
//rigidbody2d.rotation = Mathf.Atan2(move.y, move.x) * Mathf.Rad2Deg; //rotate on a dime but it's too much
}
else
{
playerControlling = false;
}
rigidbody2d.AddForce(move);
}
}
Your answer
Follow this Question
Related Questions
My player is not rotating upwards when it moves upwards. Any advice? 1 Answer
Shooter 2D - Problem with rotation of bullet to face direction (velocity) 2 Answers
Bullet follows player mouvement when It instintiates. 1 Answer
How to Continue Enemy Movement Without Updating the Position 0 Answers
Can anybody help me with this? Character bodying is falling apart. 0 Answers