- Home /
Question by
Bulle51 · Mar 08, 2021 at 05:55 PM ·
rotatemovement scriptscaling
I want to make a paper Mario like flip animation for when my player walkin left and right.
It's a top down 2d rpg. I want to make the player do a smooth flip where it first shrinks down to 0 and then up again but flipped. All in code.
I wrote this code to make the player flip when walking left and right. (Movement part from Brakeys)
private Vector2 movement;
void Update()
{
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
}
void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.deltaTime);
if (movement.x == 1)
{
transform.localScale = new Vector3(-1, 1, 1);
}
if (movement.x == -1)
{
transform.localScale = new Vector3(1, 1, 1);
}
}
How do I do to make it shrink slowly and expand flipped? I have watch way to many tutorials and not understand anyting.
Comment