This Doesn’t seem to work, it functions the same as if there were no !TheAudioSource.isPlaying exists
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rocket : MonoBehaviour
{
Rigidbody TheRigidbody;
AudioSource TheAudioSource;
void Start()
{
TheRigidbody = GetComponent<Rigidbody>();
TheAudioSource = GetComponent<AudioSource>();
}
void Update()
{
ProcessInput();
}
private void ProcessInput()
{
if (Input.GetKey(KeyCode.Space))
{
TheRigidbody.AddRelativeForce(Vector3.up);
if (!TheAudioSource.isPlaying)
{
TheAudioSource.Play();
}
else
{
TheAudioSource.Stop();
}
}
if (Input.GetKey(KeyCode.A))
{
transform.Rotate(Vector3.forward);
}
else if (Input.GetKey(KeyCode.D))
{
transform.Rotate(-Vector3.forward);
}
}
}