Boost Project: AddRelativeForce Issue, Again!

My rocket is launched fine along its local Y axis by the thrust value ( initialized in movement.cs) by using
AddRelativeForce and Vector3.up

It continues to work as the rocket is rotated left and right. However, if the rocket rotates beyond about 220 deg in either direction, the local upward thrust seems to stop working. In other words, I can’t get my rocket to do a nose dive or make any steep dive towards its destination.

I can’t increase the thrust value right from the start or the rocket would just fly off literally to outer space .
I have tried with both time.DeltaTime and without - and varying the mass value … but this problem remains.

Any suggestions?
I am using Unity 2021.3.2f1

Hi Shriram,

Actually, AddRelativeForce does not have anything to do with the rotation. The method moves the rocket forwards along the local y-axis (because we pass on that axis to the method).

What exactly happens when the rocket rotated beyond 220 degree? Doesn’t the gravity work on the rocket either?

Maybe you could create a new method in your class: FixedUpdate. It is a Unity method like Update. Move the code for moving and rotating the rocket to the FixedUpdate method. Remove Time.deltaTime from the FixedUpdate method. Save your script and test your game again. Did this fix it?

If FixedUpdate solved the problem, the reason was the physics simulation. Aaaactually, Rigidbody methods are supposed to be called in FixedUpdate, not in Update. For reason of simplicity, Rick started with the Update method to not confuse any beginners.


If the FixedUpdate method did not fix the issue for you, try to pass on a second argument to the AddRelativeForce method. The syntax is simple:

rb.AddRelativeForce({whatYouHave}, ForceMode.Force);

ForceMode.Force is the second argument, and you separate it with a comma from the first argument. There are different ForceMode values. Scroll down to the bottom on this page. If ForceMode.Force did not fix the problem, test the next. Don’t forget to save your script before testing your game.

Thanks Nina, I will try out all your suggestions and report back.

In answer to your question:
After an angle of approximately 220 degrees, the rocket just seems to drift off or it just stalls. There is no downward motion towards the target even if the rocket is pointing straight down. Even gravity dosent seem to be working on it.

Hi Nina,
Thank You for your suggestions. Something seems to have improved,
it could be the Fixedupdate or the removal of timeDeltaTime.

The thrust is working now (meaning move the rocket forward along its local up axis) even if the rocket is rotated beyond 220 degrees.

There is also a certain relation that has to be maintained between the forward speed and rotation speed, I find.

Its still not perfect - but playable.
I would like to upload it for people (who can play games better than I can ) … which is nearly everybody - to try it out and give me feedback on how to make the core-mechanic work better.

But I am not sure how to upload the build which I have created for PC.
Should I create a build for webGL and upload that here?

Good job on improving the movement of the rocket. :slight_smile:

If you want to allow people to play your game without downloading an exe file, the best would be to build your game to WebGL. Then you could upload it to sharemygame.com and share the link. You may also share incomplete games this way to show, for example, problems.

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

Privacy & Terms