Hell, I’m doing the project Boost lessons, and I’ve decided to make my own as a challenge.
As who doesn’t love a challenge?
My version still a Rocket Lander but in 3D with the right stick on my joypad to rotate the camera around the rocket, and the left joystick to up and rotate the Rocket.
Now, I know this out of the scope of the course, but I wondered how would I make the camera rotate the ship/camera/view 45 Degrees each tap of the right joystick and only do it once or have a delay after each rotation.
I’ve got it to rotate around the ship and I did get it to do 45 Deg jumps, but there was no pause between jumps, so it was unusable.
Here comes my horrible code
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
float thrustPower = 1000;
float rotatonThrust = 30;
Rigidbody rb;
Camera cam;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
ProcessInput();
ProcessRotation();
ProcessCameraRotation();
}
private void ProcessRotation()
{
if (Input.GetAxis("Horizontal") < 0)
{
RotateMovement(rotatonThrust);
}
else if (Input.GetAxis("Horizontal") > 0)
{
RotateMovement(-rotatonThrust);
}
}
private void RotateMovement(float direction)
{
transform.Rotate(Vector3.forward * direction * Time.deltaTime);
}
void ProcessInput()
{
if(Input.GetAxis("Vertical") >0 )
{
rb.AddRelativeForce(Vector3.up * thrustPower * Time.deltaTime);
}
}
void ProcessCameraRotation()
{
if (Input.GetAxis("Roll") < 0)
{
transform.Rotate(new Vector3(0, Input.GetAxis("Roll") * 1000f * Time.deltaTime, 0));
}
if (Input.GetAxis("Roll") > 0)
{
transform.Rotate(new Vector3(0, Input.GetAxis("Roll") * 1000f * Time.deltaTime, 0));
}
}
}
I know this code is horrible I’ve yet to tidy it up.
If this is too much out of the remit of the course admins please delete it