Frustrating issue

Video included to show what i mean.

i have my rocket setup but when i play i have to have rocketed selected to use the settings i have set for it if anything else is highlited it looses the settings or when a new level starts its like the rocket is reset so have to go back in to hierarchy and highlight it.

https://youtu.be/r_19nmY3MJc

Hi Lee,

There is a strange bug in Unity which prevents the rocket from flying properly when it is selected in the Hierarchy. Try to select something else and click into the game window once to set Unity’s focus on the game window again.

1 Like

I came here and this was the first post. Thank you for helping me understand.

I’m assuming there is no fix? When we build the game that will surly go away as we cannot click within the hierarchy.

Hi Collin,

I don’t know any fix. Fortunately, the bug does not affect your final build. If the issue persists in the build, there must be an issue somewhere in your project.

The game window in the Unity editor is just a preview. It’s often a bit laggy. For this reason, it could make sense to occasionally build the game and test the build.

Here is a potential solution:

// in Rocket.cs

bool isThrusting = false;

private void RespondToThrustInput()
{
    isThrusting = Input.GetKey(KeyCode.Space);

    if (isThrusting)
    {
        ApplyThrust();
    }
    else
    {
        audioSource.Stop();
        mainEngineParticles.Stop();
    }
}

private void ApplyThrust()
{
    if (!audioSource.isPlaying)
    {
        audioSource.PlayOneShot(mainEngine);
    }

    mainEngineParticles.Play();
}

private void FixedUpdate()
{
    if (isThrusting)
    {
        rigidBody.AddRelativeForce(Vector3.up * mainThrust, ForceMode.Acceleration);
    }
}

Did this fix the issue?

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

Privacy & Terms