• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by TheSoloPlayer · Nov 06, 2016 at 09:05 PM · unity 53dforcerocketconstantforce

How do I make a rocket?

I'm trying to create a rocket, where you would press the space bar, and hold it to keep going up, and you could use wasd to control which way the rocket faces. How would I create a rocket like this? I had looked at a video of how to do it with constant force, but for some reason Unity came up with an error that "constantForce" was obsolete. I found that strange especially since it was a component that I could add to the rocket itself. Any help?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Developer1212 · Nov 06, 2016 at 09:46 PM

You can use the AddForce () function instead of the constant force function.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Makri907 · Nov 06, 2016 at 10:33 PM 0
Share

Rigidbody.AddForce() only applies force for one frame and returns to zero. Constant force is constantly applying force and only changes when the force or torque value is changed.

avatar image Developer1212 · Nov 06, 2016 at 10:37 PM 1
Share

Not if you use it like this:

 if (Input.Get$$anonymous$$ey($$anonymous$$eyCode.Space)) {
 rigidbody.AddForce (Vector3.something * Time.deltaTime);
 }
avatar image
0

Answer by Makri907 · Nov 06, 2016 at 10:28 PM

IMPORTANT: Be sure to add a Constant Force Component to your rocket. Create a C# script on your rocket and attach this to it:

     ConstantForce thrust;
             public Vector3 rocketDirection;
             Vector3 copy;
             public float xlrate;
             void Start () {
                 thrust = gameObject.GetComponent<ConstantForce> ();
                 copy = rocketDirection;
             }
             
             void Update () {
                 if (xlrate >= 20f) {
                     xlrate += .025f;
                 }
                 if (Input.GetKey (KeyCode.Space)) {
 thrust.force = rocketDirection * xlrate;
                     rocketDirection = copy;
                 }
                 if (Input.GetKeyUp (KeyCode.Space)) {
 thrust.force = rocketDirection * xlrate;
                     rocketDirection = Vector3.zero;
                 }
             }
         }

Note: Set the xlrate to something reasonable like 2 or 3. And for the Y position on rocketDirection, somewhere between 10 and 20.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

119 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rocket Landing 1 Answer

I'm having a few issues with (Catmull)Splines that i need help with. 1 Answer

How can I make a game similar to Lego Universe (sort of like a replica) 0 Answers

Animation on raycast enter trigger ? 0 Answers

3D Game Kit - Ellen dies when she jumps, she dies when game starts, she also keeps on dying after respawning once. 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges