using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rocket : MonoBehaviour
{
AudioSource audioSource;
Rigidbody rigidBody;
// Start is called before the first frame update
void Start()
{
audioSource = GetComponent();
rigidBody = GetComponent();
}
// Update is called once per frame
void Update()
{
ProcessInput();
}
private void ProcessInput()
{
if (Input.GetKey(KeyCode.Space)) //can thrust while rotating
{
if (!audioSource.isPlaying)
{
audioSource.Play();
}
rigidBody.AddRelativeForce(Vector3.up*Time.deltaTime*60);
}
else
{
audioSource.Stop();
}
if (Input.GetKey(KeyCode.A))
{
transform.Rotate(Vector3.forward*Time.deltaTime*50);
}
else if (Input.GetKey(KeyCode.D))
{
transform.Rotate(-Vector3.forward*Time.deltaTime*50);
}
}
}