Hi guys,
I have an object where the user can control it on top of a hill. I added a rigidbody as well as physic material (to both the object and terrain) to make it slide down the hill. The speed is of the object based on gravity to move it downwards. The problem is when the user turns left or right while sliding down the hill it doesn’t move in that direction, it just still goes straight down the hill. I have no idea on how to make the player move left or right on the hill while still using gravity to push them.
E.g snow skiing where you can go straight down or turn left or right to move on the side of the hill. here is what I got so far
public float acceleration;
public float turnSpeed;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
{
transform.Rotate(0, -turnSpeed, 0);
}
if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
{
transform.Rotate(0, turnSpeed, 0);
}
}
Thanks for your help