Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Dilaxer01 · Dec 27, 2019 at 01:21 PM · movementcollidertriggercharactercontrollerjumping

Why can't I properly jump?

Hello, merry Christmas!

When I'm on the "proper" ground (in this case a platform), I can jump with proper force. (The platform has a "Ground" layer set). But when I jump on the "Commercials", which are also set on the "Ground" layer, my first jump on them is noticeably weaker. The commercials have a BoxCollider2D, but they are intentionally set on Trigger, because I don't want the player to be able to walk on the commercials, but rather use them as an opportunity to jump onto another commercial and so on.

![alt text][2] [2]: /storage/temp/150526-weirdjump2.gif

The first script:

alt text

This is the second script:

 public class Controller : MonoBehaviour
 {
     public CharacterController2D controller;
 
     float moveHorizontal;
     public float speed;
     bool jump = false;
 
     void Update()
     {
        moveHorizontal = Input.GetAxisRaw("Horizontal") * speed;
 
        if (Input.GetButtonDown("Jump"))
         {
             jump = true;
         }  
     }
 
     void FixedUpdate()
     {
         controller.Move(moveHorizontal * Time.deltaTime, jump);
         jump = false;
     }   
 }

weirdjump2.gif (359.8 kB)
capture.jpg (68.6 kB)
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 akaBase · Dec 27, 2019 at 01:34 PM 0
Share

Check in the settings that QueryTriggerInteraction is set to true, it migth be that when you are raycasting to test for ground its not querying the trigger collider.

avatar image Dilaxer01 akaBase · Dec 27, 2019 at 01:41 PM 0
Share

Where do I find this "QueryTriggerInteraction"?

avatar image akaBase Dilaxer01 · Dec 28, 2019 at 01:00 PM 0
Share

Edit -> Project Settings -> Physics/Physics2D


Also you can often set this in the Raycast too.

2 Replies

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

Answer by Twinklier · Dec 29, 2019 at 07:27 AM

Imagine this in slow motion. You hit jump, you add force m_JumpForce, you go up, and slowly fall. You have a downward velocity. You jump again, adding force, but that has to fight with the donward velocity.

It's like when you're falling from a plane, you can't just take off you shoes and jump on it to break your fall. Yes, you'd slow down slightly with the force from that jump, with it's not enough to counteract the speed of your fall. You'd have to completely remove your downward velocity before you do a second jump.

Just getting you into the mindset, enough of the bs.

Just set your m_RigidBody.velocity = new Vector3(m_RigidBody.velocity.x, 0, m_RigidBody.velocity.z); right at the instance before you addforce. This ensures that the downward velocity is 0, thus you addforce wouldn't have to fight anything. Or, directly change your velocities (m_RigidBody.velocity += Vector3.up * m_JumpForce) . This ensures that every jump, you starting upward velocity is the same.

Cheers!

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 Dilaxer01 · Dec 29, 2019 at 11:40 AM 0
Share

It worked! Thank You so much!

avatar image Twinklier Dilaxer01 · Dec 29, 2019 at 12:54 PM 0
Share

cheers pal!

avatar image
0

Answer by marioluigivideo · Dec 30, 2019 at 10:03 AM

Hey, here's a video of Brackeys where he uses the same Player Controller script as you: https://www.youtube.com/watch?v=dwcT-Dch0bA If you follow his instructions, your problem will certainly be solved.

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

226 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I detect when two CharacterControllers collide? 0 Answers

Moving objects using raycasting? 1 Answer

How to "push" CharacterController off of a wall's surface normal? 1 Answer

CharacterController doesn't work with collider 1 Answer

How to keep current velocity while jumping? 0 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