How would I go about making a rocket player controller rotate around its bottom part?
Heres my code up until now (I know it has problems, it's just a proof of concept for now)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rocket : MonoBehaviour
{
Rigidbody rigidBody;
void Start()
{
rigidBody = GetComponent<Rigidbody>();
}
void Update()
{
ProcessInput();
}
private void ProcessInput()
{
if (Input.GetKey(KeyCode.Space))
{
rigidBody.AddRelativeForce(Vector3.up);
}
if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
{
if (!Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.RightArrow))
{
transform.Rotate(new Vector3(0, 0, 2));
}
}
if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
{
if (!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.LeftArrow))
{
transform.Rotate(new Vector3(0, 0, -2));
}
}
}
}