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
1
Question by Alex Cook · Feb 26, 2011 at 06:09 PM · movementcharactercontrollerflying

Character moving up/down & left/right while constantly going forward in Z

I'm attempting to create a 'flying' character that the player can move up or down on the y axis and left or right on the x axis, while constantly moving forward in the z axis.

The problem I'm seeing is that the player gets 'stuck' for lack of a better term on the x axis. The model will move a few pixels to the right, for example, then stop while still being able to move over to the left without issue. What I don't understand is why the player moving on the y axis isn't doing the same thing.

WEB PLAYER http://acjcllc.com/unity/WebPlayer/WebPlayer.html

This is the script I'm using:

var speed:float = 10.0;

private var thisTranform:Transform; private var thisCharacter:CharacterController;

function Start () { thisTranform = GetComponent(Transform); thisCharacter = GetComponent(CharacterController); }

function Update() { dir = new Vector3( Input.GetAxis("Horizontal") Time.deltaTime speed, Input.GetAxis("Vertical") Time.deltaTime speed, 0.25 ); Debug.Log(dir); thisCharacter.Move(dir); }

NOTE: The player is controlled with a Character Controller, not a Rigidbody. I've tried both FixedUpdate and Update without any change in behavior.

Any idea of why this is happening? Or, if there is a better way to do it, how? Links to tutorials / explanations appreciated.

Thanks!

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
Best Answer

Answer by Mike 3 · Feb 27, 2011 at 06:45 PM

Is it possible that you have attached a cube collider to the character controller?

If you have both on, it's likely that there will be collision between the two, screwing things up somewhat

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 Alex Cook · Feb 27, 2011 at 06:55 PM 0
Share

that was exactly it - I had a box collider on the cube, which was a child of the game object with the script. Thanks!

avatar image dataxpress · Nov 04, 2012 at 09:17 PM 0
Share

Solved my problem, too!

avatar image
0

Answer by iuhfewkjbwekj · Aug 17, 2013 at 09:38 PM

Delete the 0.25 under the Input.GetAxis.

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

2 People are following this question.

avatar image avatar image

Related Questions

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

Character Controller - unknown rotation, flying 1 Answer

Jet-Pack Script 1 Answer

CharacterController unexpectedly moving up 0 Answers

Input.GetAxis won't start working properly. 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