# ,How do I make the velocity of my sprite move in the same direction of its rotation?

I’m experimenting with Unity Remote 5, and I set up a simple scene with a wave and 2 buttons. The wave is constantly moving up. When I press the button on the left my sprite slightly rotates towards that direction, same with the right button. When a button is pressed, I want to change the velocity of my sprite to align with its current rotation

This is my script:

``````using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class PlayerMove : MonoBehaviour
{
public Rigidbody2D rb;
public float movespeed;
private float direction;
public GameObject player;

public Button leftBtn, rightBtn;
int TappedLeft = 0;
int TappedRight= 0;

bool Right;
bool Left;

void Start()
{
rb = GetComponent<Rigidbody2D>();
}

// Update is called once per frame
void Update()
{
direction = Input.GetAxisRaw("Horizontal");
rb.velocity = new Vector2(0f, movespeed);

}

public void TiltLeft()
{

if (TappedLeft < 1)
{
player.transform.rotation = Quaternion.Euler(0f, 0f, 45f);
TappedLeft += 1;
}
TappedLeft -= 1;

}

public void TiltRight()
{

if (TappedRight < 1)
{
player.transform.rotation = Quaternion.Euler(0f, 0f, -45f);
TappedRight += 1;
}
TappedRight -= 1;
}
}
``````

Transform.forward is the forward vector of local relative rotation of the object