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 Anthriax · Mar 12, 2015 at 04:14 PM · movementgravitymovement scriptflying

Charactercontroller won't go down, only goes up

Hey i have a player with a charactercontroller and an easy movementscript to walk. (player don't need to jump or something like that). but if it walk over a little blok. my player moves up. and is kind of flying above the ground. if go up a stair he keeps flying at that level. but my player won't go down.

sorry for my bad english . thanks for reading

(this is my movementscript)

   public float MoveSpeed = 100f;
   public bool attacking=false;
   public bool IsWalking;
   public CharacterController controller;
   Vector3 lastPos; 
 
   void Start()
   {
     lastPos = transform.position;
   }
 
   void Update()
   {
    if (GameObject.Find("Cha_Knight").GetComponent<PlayerHealth>().currentHealth > 0)
     {
       Vector3 curPos = transform.position;
 
 
       if (Input.GetKey("z"))
       {
         controller.Move(Vector3.forward * MoveSpeed * Time.deltaTime);
         animation.CrossFade("Walk");
         transform.forward = new Vector3(0, 0f, 1f);
         IsWalking = true;
 
         if (lastPos == curPos)
         {
           IsWalking = false;
         }
 
 
 
       }
 
 
 
 
 
       else if (Input.GetKey("s"))
       {
         controller.Move(-Vector3.forward * MoveSpeed * Time.deltaTime);
         transform.forward = new Vector3(0, 0f, -1f);
         animation.Play("Walk");
         IsWalking = true;
 
         if (lastPos == curPos)
         {
           IsWalking = false;
         }
 
       }
 
 
 
       else if (Input.GetKey("q"))
       {
         controller.Move(-Vector3.right * MoveSpeed * Time.deltaTime);
         transform.forward = new Vector3(-1f, 0f, 0);
         animation.CrossFade("Walk");
         IsWalking = true;
         if (lastPos == curPos)
         {
           IsWalking = false;
         }
 
 
       }
 
 
 
       else if (Input.GetKey("d"))
       {
 
         controller.Move(Vector3.right * MoveSpeed * Time.deltaTime);
         transform.forward = new Vector3(1f, 0f, 0);
         animation.CrossFade("Walk");
         IsWalking = true;
 
         if (lastPos == curPos)
         {
           IsWalking = false;
         }
 
 
       }
 
 
       else
       {
         IsWalking = false;
       }
 
 
 
       //animation.CrossFade("Wait");
 
       lastPos = curPos;
 
 
 
 
     }
 
 
   }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Ulydev · Mar 12, 2015 at 06:20 PM

In order to make your player touch the ground, you need to apply gravity.

You have two ways of doing it : either apply it manually, or use controller.SimpleMove() instead of Move().

http://docs.unity3d.com/ScriptReference/CharacterController.SimpleMove.html

Comment
Add comment · Show 3 · 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 Anthriax · Mar 13, 2015 at 12:47 PM 0
Share

thanks , i try the simplemove command out. if i aplied manualy gravity my player just went trough the ground. so that didn't worked. ( already tried that)

avatar image Anthriax · Mar 13, 2015 at 01:00 PM 0
Share

if i change it to simplemove. my character rotate but just falls trought the ground if i press one the keys

avatar image Anthriax · Mar 14, 2015 at 09:47 AM 0
Share

i have no button "Generate Colliders". isn't that for a rigidbody?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Make character move left or right only if it is in the air,Make character move left or right only in the air. 0 Answers

When my object tilts back the foreword movement lifts it off of the ground. how do i keep it grounded 2 Answers

Rigidbody--Addforce on a Spherical Platform(A Globe) 2 Answers

Script click to move not working, MoveTowards always move forward 3 Answers

How do i maintain the same speed in the 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