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
1
Question by onionman99 · Nov 13, 2013 at 05:58 AM ·

jumping with a character controller

i am making a simple 2d game and am using a character controller for my movement. i want the character to have a smooth jump but the script im using makes it instantly jump up and slowly fall back down. how can i make the jump smooth? this is the script im using:

 var jump : int = 10;
 
 function Update()
 {
    if(Input.GetButtonDown("Jump") && controller.isGrounded)
       {
          transform.Translate(0, jump * Time.deltaTime, 0);
       }

}

Comment
Add comment · Show 2
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 fafase · Nov 13, 2013 at 05:59 AM 0
Share

See here http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.$$anonymous$$ove.html

the script has it all, movement and jump.

avatar image onionman99 · Nov 13, 2013 at 06:28 AM 0
Share

how do i do this without the movement parts?

3 Replies

· Add your reply
  • Sort: 
avatar image
6

Answer by mattssonon · Nov 13, 2013 at 08:56 AM

Use .Move or .SimpleMove when using a Character Controller. Using the example code in http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.Move.html you would do this to jump:

 public float jumpSpeed = 8.0F;
 public float gravity = 20.0F;
 private Vector3 moveDirection = Vector3.zero;
 
 void Update() {
     if (controller.isGrounded && Input.GetButton("Jump")) {
         moveDirection.y = jumpSpeed;
     }
     moveDirection.y -= gravity * Time.deltaTime;
     controller.Move(moveDirection * Time.deltaTime);
 }
Comment
Add comment · Show 2 · 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 jelmei123456789 · Aug 28, 2018 at 09:09 AM 0
Share

thank you so much you just saved my life O_o I have searched the intire internet for a smooth jump on a character controler but it is nowhere! thank you so much ;-;

avatar image zedix28 · Apr 01, 2021 at 06:53 PM 0
Share

It's really glitchy when you collide with an object.

avatar image
0

Answer by CriticalAngleStudios · Jun 04, 2019 at 05:42 AM

How does that work? It's setting the moveDirection's Y instantly. How can it possibly be smooth?

Comment
Add comment · Show 1 · 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 N-8-D-e-v · Dec 25, 2020 at 08:46 PM 0
Share

CharacterController.$$anonymous$$ove interpolates automatically I believe, although this is without actually checking the docs so please correct me if I am wrong

avatar image
0

Answer by zedix28 · Apr 02, 2021 at 12:15 PM

The code that @mattssonon provided gets really glitchy when you collide with an object. How do I fix that?

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

20 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

Related Questions

N00b question: how to implement direct transform manipulation collisions? 1 Answer

death script remains ineffective 1 Answer

Is it possible to load a script to a gameobject, run it then destory it? (Onetime script) 1 Answer

Door - Press button to open 1 Answer

Best practice for properties "get{} set{}" ? 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