Unity Challenge Complete
- Keshav Batra
- Oct 7, 2022
- 1 min read
I finally completed my unity challenge and it turned out great. The first thing I worked on was having the camera follow the plane. Then I worked on the movement of the plane going up and down. Finally I finished up by making the propeller move. The final result ended up like this:
I've realized that when its in the x axis, the plane will turn up and down and when its in the y axis it turns right and left. I had to use vector3.right to make it go up and down.
void FixedUpdate()
{
// get the user's vertical input
verticalInput = Input.GetAxis("Vertical");
// move the plane forward at a constant rate
transform.Translate(Vector3.forward * speed);
// tilt the plane up/down based on up/down arrow keys
transform.Rotate(Vector3.right * rotationSpeed * verticalInput * Time.deltaTime);
}
This is what makes the plane go up and down.
void Update()
{
transform.Rotate(Vector3.forward * rotationSpeed * Time.deltaTime);
}
The propeller movement which was set to 3000.
void Update()
{
transform.position = Player.transform.position + offset;
}
The camera following the plane
댓글