So’ve been trying the challange for half an hour now, but my nearest possible ressult is the game just throwing audio explosions at me as soon as i hit space
heres my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RocketKeyInput : MonoBehaviour
{
AudioSource myAudioSource;
Rigidbody rigidBody;
bool playmusic;
// Start is called before the first frame update
void Start()
{
rigidBody = GetComponent<Rigidbody>();
myAudioSource = GetComponent<AudioSource>();
playmusic = false;
}
// Update is called once per frame
void Update()
{
ProcessInput();
if (playmusic == true)
{
myAudioSource.Play();
}
if (Input.GetKey(KeyCode.Space))
{
playmusic = true;
if (Input.GetKeyDown(KeyCode.Space))
{
playmusic = false;
myAudioSource.Stop();
}
}
void ProcessInput()
{
if (Input.GetKey(KeyCode.A))
{
transform.Rotate(Vector3.forward);
}
else if (Input.GetKey(KeyCode.D))
{
transform.Rotate(-Vector3.forward); // notice the -
// you can also type (Vector3.back)
}
}
}
}