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 ddmx · Feb 23, 2013 at 12:57 AM · charactercontrollerjumphead

(Solved) Character Floats After Hitting Head on Object

Basically the character is "hanging" after you jump and he hits his head on a platform only while move left or right. If you are standing still he hits his head and returns normally to the ground (mario style). If you are moving to the left or right he will float for a short while until gravity picks him back up again. If you leave from under the platform you hit he falls normally right away.

It's a problem that I've had since the beginning and I'll spend a few hours trying to fix it, leave defeated only to come back and spend a few more hours on it another day. The cycle repeats. Any help would be immensely appreciated! :)

Cheers

 // Move the controller, and set collidedDown true or false depending on whether we're standing on something
         flags=controller.Move(moveDirection*Time.deltaTime);
                 
         //Detect character controller collision        
         collidedDown=(flags & CollisionFlags.CollidedBelow)!=0;
         collidedUp=(flags & CollisionFlags.CollidedAbove)!=0;
         collidedSides=(flags & CollisionFlags.CollidedSides)!=0;
         
         if(collidedUp){
             moveDirection.y=0;
         }
         
         // Apply gravity
           moveDirection.y -= gravity * Time.deltaTime;
Comment
Add comment · Show 3
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 Benproductions1 · Feb 24, 2013 at 01:29 AM 0
Share

so I made my comment an answer and put the corrected code in there :) would you please click on the tick button under the dislike to accept it :)

avatar image AlucardJay · Feb 24, 2013 at 03:49 AM 1
Share

@ddmx do not edit the title as solved. How to accept an answer :

On the left-hand-side of the Answer box , there are the following icons :

 Thumb Up
 Number (of votes)
 Thumb Down 
 A Tick/Check $$anonymous$$ark

If an answer worked for you , click on the 'Tick' , the answer should now be highlighted in green. If you like an answer on Any question , you can click on the Thumb UP , the thumb should now be highlighted in green , and the number of votes should rise by 1.

When your karma rises above 15, you can upvote any answer (on any question) you like or think is correct, this gives the person karma for their time and effort.

Watch : http://video.unity3d.com/video/7720450/tutorials-using-unity-answers

avatar image ddmx · Feb 25, 2013 at 04:19 AM 0
Share

Thanks for pointing that out. I checked it and now everyone should get the credit they deserve. :)

Cheers

1 Reply

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

Answer by Benproductions1 · Feb 23, 2013 at 04:14 AM

Your problem is, that your setting move direction to 0. When your character hit's something, it goes "into" it, so for a short amount of time his velocity will always be 0 how about setting it to 0 only if it's above 0?

 if (collidedup && moveDirection > 0) {
     moveDirection = 0;
 }
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

11 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

Related Questions

controller.Move not working correctly 0 Answers

How to make the CC(character controller) jump and push 1 Answer

Character Jumping Not Working Sometimes 1 Answer

can anyone help me to smooth the jump? 0 Answers

tring to make a jump pad in fps 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