void FixedUpdate()
{
//Movement
float moveHorizontal = Input.GetAxis(“Horizontal”);
float moveVertical = Input.GetAxis(“Vertical”);
Vector3 movement = new Vector3(moveHorizontal, 0, moveVertical);
rb.AddForce(movement * speed);
//launch player
if (Input.GetKeyDown(KeyCode.Space))
{
rb.velocity = new Vector3(0,0,launchSpeed);
}
The player is a rolling ball(rigidbody). I’m fine with the current movement but i’m trying to make the player launch in the direction it’s moving when I press space. How do i do this?
Thanks!