Different Kinda Logic Applied but got the same result, is it a good practice?

Looping is Off
[SerializeField]AudioClip mainEngine;

 [SerializeField]ParticleSystem LeftThrust;

 [SerializeField]ParticleSystem RightThrust;

 [SerializeField]ParticleSystem MainThrust;    

// 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 * Thrust * Time.deltaTime);

        // audio settings

         if (!audioSource.isPlaying)

        {

            MainThrust.Play();

            audioSource.PlayOneShot(mainEngine);

        }

    else

        {

            MainThrust.Stop();

            audioSource.Stop();

        }          

    }

}    

    void ProcessRotation()

{    

    {

        if (Input.GetKey(KeyCode.A))

        {

            LeftThrust.Play();

            FrameRotation(rotationSpeed);                

        }

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

        {

            RightThrust.Play();

            FrameRotation(-rotationSpeed);

        }

        else

        {

            LeftThrust.Stop();

            RightThrust.Stop();

        }

Hi Aleksi,

Welcome to our community, and good job on developing your own approach! :slight_smile:

Did you test your code? Does it work? If so, it’s a solution.


See also:

ya, it works perfectly fine and operates as same as Rick’s, i just wanted to make sure whether its a healthy practice or not? :sweat_smile:

I did not see any issue in your code. Is there something where you feel that might cause problems down the road?

not particularly, everything seems fine!

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

Privacy & Terms