Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 /
avatar image
0
Question by neko_san · Oct 24, 2011 at 08:34 PM · rigidbodyinput

Making a ship move

Hello guys

I'm trying to make a small ship game, where the ship floats a bit above the ground, and of course you can move it forward/backward using the arrow keys, and also turn left/right. Think of the ships in WipeOut.

Since I'm new with Unity and I want to test stuff first, what I did was create a cube, set it as a rigidbody, then added a box for collision. All is fine and the object collides with the track mesh.

My question is, how do I apply movement to the ship?

In my code so far I have something like this:

function FixedUpdate () {
  forward = Input.GetAxis("Vertical");
  //Debug.Log ("Moving forward"+forward+" with deltatime="+Time.deltaTime);
  if (forward)
      rigidbody.AddForce(Vector3.forward * 5000 * forward * Time.deltaTime);
}

This seems to push the ship forward, although irregularly (it's more like it's going over a rocky terrain rather then a plain terrain) and of course it does not use the "ship's"(cube's) forward vector (Z axis). Once it collides and the cube rotates, pressing Arrow up does not move the cube forward but sideways. Do I or how do I specify that it should use the ship's Z axis always, and to make the movement constant over a period of time (say 10 meters/second). Do I use Time.deltaTime or something else since I use FixedUpdate and not Update?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by anihilator511298 · Oct 25, 2011 at 01:02 AM

I am not very experienced in unity, but you might try importing a character controller (go to assets, import new asset.). The put you ship model under the First Person Controller Tab and deleting the graphics thing in the same tab. then configure click on main camera in that tab and move it to a 3rd person view of your ship. you can also move the ship so it sits a little off the ground or wherever you want it, just make sure you clicking on the children ( i think that's what there called, again have only been using unity for a month. in other words, the things underneath the first person controller tab in the hierarchy) and only moving them, then your ship can move up/down without actually moving the ship, just position it (if you dont understand just try it and you'll see what i mean.). I did this for a car, and the only problem i have run into is wile moving the ship you slide and you have to steer with the mouse. Again your taking advice from a noob, so if it works for you then fine if it doesnt oh well lol.

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

rigidbody.isKinematic = false Does NOT Work 2 Answers

RigibBody and ignored Input.GetKeyDown 0 Answers

3D world 2D gameplay, keep player in the camera? 1 Answer

Player object falling slowly when holding input 2 Answers

Falling object touch 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges