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 Sueko · Nov 05, 2012 at 02:42 AM · charactercontrollermovesimplemove

Switching from SimpleMove to Move

Hi there!

I have an AI driven character that has been using CharacterController.SimpleMove so far, and all good. But now I need this character to jump. When trying to switch over CharacterController.Move, my character suddenly starts moving in a different manner, even if I use the same direction vector.

I used to move my character this way:


  Vector3 dir = (targetPosition - transform.position).normalized;
  dir *= speed * Time.fixedDeltaTime;
  controller.SimpleMove (dir);

If I just change ".SimpleMove" in this code to ".Move" , the character will run move much faster. Why is that? What can I do to behave same way as with SimpleMove?? Is it because of the gravity? What is the gravity SimpleMove applies?

Thanks!

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 prototype7 · Nov 10, 2012 at 08:14 AM 0
Share

Did you check if the character is grounded ?
look this sample code below

     public float jumpSpeed_ = 8.0F;
     public float gravity_ = 20.0F;
     public float acceleration_ = 10.0F;
     public float maxSpeed_ = 100.0F;
     public float curSpeed_ = 10.0F;
     private Vector3 moveDirection = Vector3.zero;
     public CharacterController controller_;
     
     // Update is called once per frame
     void Update () {
         if(controller_.isGrounded)
         {
             // We are grounded, so recalculate
             // move direction directly from axes
             curSpeed_ += acceleration_;
             
             if(curSpeed_ > maxSpeed_)
                 curSpeed_ = maxSpeed_;
             
             moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
             moveDirection = transform.TransformDirection(moveDirection);
             moveDirection *= curSpeed_;
             
             if(Input.GetButton ("Jump"))
             {
                 moveDirection.y = jumpSpeed_;
             }
         }
         
         // Apply gravity_
         moveDirection.y -= gravity_ * Time.deltaTime;
         
         // $$anonymous$$ove the controller_
         controller_.$$anonymous$$ove(moveDirection * Time.deltaTime);
     }

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Zinger · Dec 19, 2012 at 12:12 AM

SimpleMove is frame rate independent under the hood, meaning that it takes the input and multiplies it by Time.deltaTime (or at least that's what I assume).

Move on the other hand does not do that. So to convert from SimpleMove to Move, take your input to SimpleMove and multiply it by Time.deltaTime.

Oh and also, SimpleMove applies gravity. So there's that too.

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

12 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

Related Questions

CharacterController Move vs. SimpleMove 1 Answer

Character Controller Won't SimpleMove() 0 Answers

NPC CharacterController doesn't move or stops randomly 0 Answers

SimpleMove not working on iOS? 0 Answers

Charactercontroller.move affecting rotation 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