Need to Update Mass of Rocket Ship every time I load up my project?

I feel like every time I load up my unity game and start playing to test out a new thing the teacher (Rick or Ben? Sorry!) is showing my rocket ship won’t lift off without reducing the mass again. I’m not changing the size of my ship or anything between videos, so this is really confusing. And I think it’s affecting how it overall flies, so it takes forever to move and land cause Gravity is on and every time I have less mass. So I get the physics, but I don’t know why it seems to break between saves and loading of Unity again and again. (I tend to do a video every other day, so that’s why it seems to be “between videos”.)

I’ve got this image of my rocket ship’s current settings that I’ve applied to the Prefab, and I can share more, I just didn’t know what all would help. I’ve also got VC going, so I can upload that somewhere to share if that would be more helpful.

Thanks!

1 Like

Hi,

There is a strange bug in Unity which prevents the rocket from flying 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:

1 Like

Apologies for the long time to respond, just now got back to this today. I reset my mass to 0.1 as is the lecturer’s and unselected the rocket ship, and about every 1/10 plays, it kind of works, as in the ship goes up! Then it seems gravity catches up to it and it won’t go anymore, even in the same “Play” session. It comes back down, even though I’m holding the thrust button down constantly.

I’m interested in testing your code example, but you’re a bit ahead of me with the mainThrust variable and mainEngineParticles. I’m on lecture 50 today, I’ll try to get your code implemented after that and see where it goes? Thank you so much for taking the time to respond! :slight_smile:

Haha! Okay, the mainThrust multiplication bit was what I needed. It consistently works now. My multiplication factor is a mass of 1 * 750f * Time.deltaTime, so not sure if that’s “normal”. But as I said, it consistently works now. Thank you!

If it works, it works. Your future players will not see the values, and they are not interested in them anyway. For this reason, the actual values do not matter as long as the rocket moves nicely. Regard Ben’s values as an example but focus on solving the problem, not on copying him. :slight_smile:

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

Privacy & Terms