using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
[SerializeField] float speed = 100f;
[SerializeField] float rotationspeed = 10f;
Rigidbody rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
ProcessThrust();
ProcessRotate();
}
void ProcessThrust()
{
if (Input.GetKey(KeyCode.Space))
{
rb.AddRelativeForce(Vector3.up * speed * Time.deltaTime);
}
}
void ProcessRotate()
{
if (Input.GetKey(KeyCode.A))
{
ApplyRotation(rotationspeed);
}
else if (Input.GetKey(KeyCode.D))
{
ApplyRotation(-rotationspeed);
}
}
private void ApplyRotation(float rotationThisFrame)
{
transform.Rotate(Vector3.forward * rotationThisFrame * Time.deltaTime);
}
}
my object moves straight up even when i rotate it?