Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 LennoxLuis · Jul 31, 2019 at 07:52 PM · charactercontroller

Character with controller flies off map.

I have just added a character controller and now every time I hit play the character starts flying off the map instantly. Anyone know how to fix that?

[1]: /storage/temp/143827-bildschirmfoto-2019-07-31-um-214919.png

bildschirmfoto-2019-07-31-um-214919.png (280.1 kB)
bildschirmfoto-2019-07-31-um-214752.png (132.0 kB)
Comment
Add comment · Show 7
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 Vega4Life · Jul 31, 2019 at 07:56 PM 0
Share

I would take off the rigid body, as a character controller has its own.... behind the scenes.

avatar image LennoxLuis Vega4Life · Jul 31, 2019 at 08:02 PM 0
Share

did not work, still flies...

avatar image Vega4Life LennoxLuis · Jul 31, 2019 at 08:04 PM 0
Share

Need some code in that playerController you have then. :)

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Vega4Life · Jul 31, 2019 at 08:10 PM

So, you are adding jumpForce to your moveDirection.y every frame... thats the issue. Should it be inside the if statement for jumping?


move this out of the if statement: moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); and put it above the if check for jumping - so you can move.

Comment
Add comment · Show 16 · 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 LennoxLuis · Jul 31, 2019 at 08:15 PM 0
Share

I deleted the code and he doesn't fly off but now he can't move.

avatar image Vega4Life LennoxLuis · Jul 31, 2019 at 08:22 PM 0
Share

move this out of the if statement: moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); and put it above the if check for jumping.

avatar image LennoxLuis Vega4Life · Jul 31, 2019 at 08:39 PM 0
Share

like this? because now i can walk perfectly. But i can't jump.

[1]: /storage/temp/143830-bildschirmfoto-2019-07-31-um-223747.png

bildschirmfoto-2019-07-31-um-223747.png (136.6 kB)
Show more comments
avatar image
0

Answer by Magso · Jul 31, 2019 at 08:20 PM

You've set moveDirection.y to the jumpForce value, thus a constant movement upwards. moveDirection.y needs to come back down to allow the character to fall. You need something like this.

 if(Input.GetButtonDown("Jump") && controller.isGrounded){
     moveDirection.y = jumpForce;
 }
 else if(!controller.isGrounded){
     moveDirection.y -= yourGravityAmount;
 }
 else{
     moveDirection.y = 0;
 }
Comment
Add comment · Show 4 · 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 LennoxLuis · Jul 31, 2019 at 08:25 PM 0
Share

I tried but it counts else as an unexpected symbol.

avatar image Magso LennoxLuis · Jul 31, 2019 at 08:31 PM 0
Share

That's peculiar. Try

 else if(controller.isGrounded){
     moveDirection.y = 0;
  }
avatar image LennoxLuis Magso · Jul 31, 2019 at 08:49 PM 0
Share

nope. doesn't work

[1]: /storage/temp/143831-bildschirmfoto-2019-07-31-um-224647.png

bildschirmfoto-2019-07-31-um-224647.png (20.1 kB)
Show more comments

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

153 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 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

Unity Flash, character jumps when the controller touches a step 0 Answers

Character - Collider With Scene 0 Answers

Character controller movement 1 Answer

Character constantly Bouncing issue 0 Answers

Make a character controller shake. 2 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