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 behzad.robot · Aug 24, 2012 at 01:38 PM · charactermoving

charactercontroller.isgrounded not working!!

Hi I'm using this code and it's not working although the character is on the ground!! It Does not work when he is on the train or on a mesh collider or on simple cube collider My Character is moving all the time And is using a character motor too!

if(Input.GetKeyDown("a") && controller.isgrounded)

{

animation.Play("ollie_flip");

transform.localPosition.x-=10;

}

What is the problem?!?! Let me tell You that controller is a variable of type : CharacterController!! Which was Assginged like this: controller = GetComponent(CharacterController);

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 behzad.robot · Aug 24, 2012 at 03:45 PM 0
Share

Does anybody needs $$anonymous$$y Full Script?!?! to Answer ;(

1 Reply

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

Answer by Mander · Aug 24, 2012 at 03:48 PM

add some gravity. that will help u. cuz sometimes it doesn't work with out it.

Comment
Add comment · Show 6 · 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 behzad.robot · Aug 24, 2012 at 03:51 PM 0
Share

What?!? Do u mean i should attach a rigidbody to the player!! Explain Please!! :O

avatar image behzad.robot · Aug 24, 2012 at 03:54 PM 0
Share

I Attached a RigidBody to the player still not working!!

avatar image Mander · Aug 24, 2012 at 03:59 PM 0
Share

no. with the character controller u can do this ezly. just add a gravity var so it is making ur CharacterController touch the ground. this is an example on how i do it for my 2.5D game. C#:

 vars:
 public float gravity = 5.0f;
 private Vector2 moveDirection = Vector2.zero;
 inside Update():
 moveDirection = new Vector2(Input.GetAxis("Horizontal"), 0);
 moveDirection = transform.TransformDirection(moveDirection);
 moveDirection.y -= gravity * Time.deltaTime;


did i explain myself? xD

avatar image behzad.robot · Aug 25, 2012 at 06:08 AM 0
Share

Thank you for answering and also that usefull answer but the problem was from this that isgrounded must be written like this: isGrounded not isgrounded! but anyway that script can be really usefull! :)

avatar image Coreyf716 · Jan 04, 2013 at 07:54 PM 0
Share

I have the same problem. Gravity doesn't work. When the player is moving, isGrounded is false. No idea why, but I'd sure like to know

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

10 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

Related Questions

how do I create a character 2 Answers

Moving character to a specific point ? 0 Answers

Platform moves when character steps on it 1 Answer

How to "Increase score with Y axis"? 1 Answer

My character jumps infinitely, even when in mid-air 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