Issues with sound and coding errors

I have Visual Studio, Unity 2020.1.17F Personal, and Windows 10 Home. Here is the issues: error CS1519: Invalid token ‘=’ in class, struct, or interface member declaration. As well as, error CS1519: Invalid token ‘void’ in class, struct, or interface member declaration. I have tried renaming the “Class” (Soundss) (another name) > I’m Just trying to figure out these issues. I would like to know that I had some trouble understanding Methods in the previous lesson of this class so I just. Any and all help would be greatly–appreciated!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movementship : MonoBehaviour
{

Rigidbody RB;
[SerializeField] float mainThurst = 100f;
[SerializeField] float rotationThrust = 1f; 
AudioSource = Soundss
// Start is called before the first frame update
void Start()
{
    RB = GetComponent<Rigidbody>();
}

// Update is called once per frame
void Update()
    {
    ProcessRotation();
    ProcessThrust();
    }
void ProcessThrust()
{

    if (Input.GetKey(KeyCode.Space))
    {
        Debug.Log("Button Space Button Press");
        RB.AddRelativeForce(0, 3, 0 * mainThurst * Time.deltaTime);
        if(!Soundss.isPlaying)
        {
            Soundss.Play(); 
        }
        
    }

}
void ProcessRotation()
{
    if (Input.GetKey(KeyCode.A))
    {
        transform.Rotate(0, 0, 1 * rotationThrust * Time.deltaTime);
        Debug.Log("Button A Press");
    }
    //if the above is not pressed then do this 
    else if (Input.GetKey(KeyCode.D))
    {
        transform.Rotate(0, 0, -1 * rotationThrust * Time.deltaTime);
        Debug.Log("Button D Pressed");
    }
    //if (Input.GetKey(KeyCode)
    {
        void ApplyRotation(float rotationThisframe)
        {
            RB.freezeRotation = true; //feezing roation so we  can manually rotate 
                                      // transform.rotate (0, 0, 1) is wrong do what is on the bottom 
            transform.Rotate(0, 0, 1 * rotationThisframe * Time.deltaTime);
            RB.freezeRotation = false;
        }
    }
}

I slove the problem. I changed the class from = to Audiosource Soundss and Added a “;” to it.

Rigidbody RB;
[SerializeField] float mainThurst = 100f;
[SerializeField] float rotationThrust = 1f;
AudioSource Soundss;
// Start is called before the first frame update

Then I did not add the following:

void ProcessThrust()
{

    if (Input.GetKey(KeyCode.Space))
    {
        // Debug.Log("Button Space Button Press");
        RB.AddRelativeForce(0, 3, 0 * mainThurst * Time.deltaTime);
        if (!audioSource.isPlaying) ;
        {
            audioSource.Play();
        }
    }
    else
    {
        audioSource.Stop();
    }
}

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms