Error while playing rocket model

https://drive.google.com/file/d/1jmqSqWDrPV4XavTGNzit3unkSU6xAAhA/view?usp=sharing
:point_up:
There is a problem facing on running the game.If I maximize the game screen the rocket boosted up,but in the minimized screen it does not show any power for boost.It means it boosted up only in maximized screen and Mass of model always remains constant.kindly check the link and suggest me why is this happening.

Thanking You.

So just to confirm you are clicked into the screen when you play… I will assume so, at that point did you compare your code to the repository?

Yes, I clicked when I play… yes I also compared the repository.

Even though I don’t do any changes and just leave the unity open 10-20 minutes then the speed of the rocket increase on its soon when hit the play button next time

Hi Atif,

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.

If that didn’t work, try to remove Time.deltaTime from the AddRelativeForce method. Alternatively, test this potential solution in the 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?

If it does and if you are experiencing issues with the rotation, you could apply this concept to the rotation code.


See also:

The actual issue is when I use unity in laptop with plugged in for charging then everything seems to be working fine. However, when its not in charging the rocket seems to be flying slowly when I run the game in unity.
So, I guess it’s the power consumption issue with laptop or unity… Not sure
Anyways, thanks for helping out, Nina

Oh, that makes sense. Laptops often come with power-saving settings. For example, if the power chord is not plugged in, certain things are disabled or don’t get full power.

1 Like

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

Privacy & Terms