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 Pirate___man · Jun 19, 2010 at 11:18 PM · javascriptcharactercontroller

CharacterController problem

... Scripting. I wrote a short script to move the spacship in my game and rotate around. here it is,

var speed = 3.0; var rotateSpeed = 3.0; function Update () { var controller : CharacterController = GetComponent(CharacterController);

// Rotate around y - axis transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);

// Move forward / backward var forward = transform.TransformDirection(Vector3.forward); var curSpeed = speed Input.GetAxis ("Vertical"); controller.SimpleMove(forward curSpeed); }

I added a character controler to my object but when I pressed play the ship didn't move fowards. The camera rotates properly but the ship only falls. how can i fix this?

Comment
Add comment · Show 1
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 Ricardo · Jun 21, 2010 at 02:52 PM 0
Share

Please title your questions in a way that are easy to find for others, and convey some information of content. "The usual Unity problem" says nothing to people who are looking at a list of questions and wondering if they're relevant to them.

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by e-bonneville · Jun 20, 2010 at 12:30 AM

You don't want to use simpleMove for this. Instead, use the more complex move command, the full documentation for which can be found here. Using this, you can opt as to whether you want to use gravity or not.

However, if you're trying to make a ship (as in Asteriods), this script may do the trick:

var rotateSpeed = 360.0; var thrustSpeed = 25.0;

function FixedUpdate() { transform.Rotate (Vector3.up (Input.GetAxis("Horizontal") rotateSpeed * Time.deltaTime) );

if (Input.GetButton("Thrust") ) { rigidbody.AddRelativeForce (Vector3.forward thrustSpeed Time.deltaTime); } }

Put it on a gameobject with a rigidbody and no character controller. To turn off gravity, just uncheck it in the rigidbody's properties. Good luck!

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 Pirate___man · Jun 20, 2010 at 06:19 PM 0
Share

When I play the game there are no errors but the ship doesn't move fowards, it just rotates...

avatar image e-bonneville · Jun 21, 2010 at 01:10 PM 0
Share

That's probably because your rigidbody is set to kinematic. Check it!

avatar image
2

Answer by Tetrad · Jun 19, 2010 at 11:29 PM

Don't use a character controller for that. I don't think you can turn off gravity on a character controller. Instead, consider using a rigid body. Alternatively, put a collider underneath your ship to "run" on.

Also, hey look at this: http://www.unifycommunity.com/wiki/index.php?title=ShipControls

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
avatar image
-1

Answer by AnaRhisT · Jun 19, 2010 at 11:30 PM

the ship falls because charactercontroller has a gravity.. u can fix it for e.g. by using transform.Translate(direction.normalized * speed) or something like that

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

No one has followed this question yet.

Related Questions

Setting Scroll View Width GUILayout 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

CharacterController unexpectedly moving up 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

2D PlatformerController: Cumulative drift? 1 Answer


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