(} expected [Assembly-CSharp]) Getting this error on the last line of code

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class Movement : MonoBehaviour

{

[SerializeField] float mainThrust = 100f; 

[SerializeField] float rotationThrust = 1f;

[SerializeField] AudioClip mainEngine;

[SerializeField] ParticleSystem mainEngineParticles;

[SerializeField] ParticleSystem leftThrusterParticles;

[SerializeField] ParticleSystem rightThrusterParticles;

  

Rigidbody rb;

AudioSource audioSource;

// Start is called before the first frame update

void Start()

{

    rb = GetComponent<Rigidbody>();

    audioSource = GetComponent<AudioSource>();

}

// Update is called once per frame

void Update()

{

    ProcessThrust();

    ProcessRotation();

}

void ProcessThrust()

{

    if (Input.GetKey(KeyCode.Space))

    {

       rb.AddRelativeForce(Vector3.up * mainThrust * Time.deltaTime);

       if(!audioSource.isPlaying)

       {

       audioSource.PlayOneShot(mainEngine);

       }

       if (!mainEngineParticles.isPlaying)

       {

       mainEngineParticles.Play();

       }

    }

    else

    {

        audioSource.Stop();

        mainEngineParticles.Stop();

    }

}

void ProcessRotation()

{

    if (Input.GetKey(KeyCode.A))

    {

        ApplyRotation(rotationThrust);

         if (!rightThrusterParticles.isPlaying)

       {

       mainEngineParticles.Play();

    }

    else if ( Input.GetKey(KeyCode.D))

    {

        ApplyRotation(-rotationThrust);

         if (!leftThrusterParticles.isPlaying)

        {

            leftThrusterParticles.Play();

        }

    }    

    else

    {

        rightThrusterParticles.Stop();

        leftThrusterParticles.Stop();

    }

}

void ApplyRotation(float rotationThisFrame)

{

    rb.freezeRotation = true; //freezing rotation so that we can manually rotate

    transform.Rotate(Vector3.forward * rotationThisFrame * Time.deltaTime);

    rb.freezeRotation = false; // unfreezing rotation so the physics system can take over

}

}

Added the bracket that I was missing but know I cant rotate right

solved

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

Privacy & Terms