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 Ultimation12 · Apr 30, 2018 at 01:37 PM · unity 2djumpinggroundedground detectionslopes

Grounded check not working on sloped ground.

Hello

In building a platformer in Unity2D, I've come across an issue. I've set up a basic check to see if my character is on the ground, where it sends a linecast from the player object to an empty child object below it and checks if the hit is a ground tag. The trouble I'm having is with sloped ground. From what I can tell, it isn't long enough to reach the slope from the angle, making it constantly show the falling animation and making the character unable to jump. I don't really want to extend it too much because a noticeable height in jumping just above the ground may appear. I'm not sure what else to do. Is there a better way to check if the character is grounded?

I can provide anything needed, like code or screenshots.

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 the_genius · Apr 30, 2018 at 01:46 PM 2
Share

You could try using more than 2 linecasts and the player is grounded if at least one of them says it is. Since the ground is sloped it will be futher bellow the player on one side (where the linecast would say it's not grounded), but on the other side of the player the slope wouldn't be as far bellow so a linecast on this side would work.

avatar image Ultimation12 the_genius · Apr 30, 2018 at 01:56 PM 0
Share

Oh wow, Can't believe I didn't think of that. Thanks! It works now.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by DawdleDev · Apr 30, 2018 at 01:50 PM

Here's an idea. Use three raycasts: one straight down and two at perpendicular angles to the slopes. Then, you can use all of them to check for the slopes on top of the ground. Another way to fix this would be to angle the raycast based on the player's direction of movement (IE moving up a slope), but this is more buggy. A third and final idea is to use a trigger under the player's feet that's the width of the player and about as tall as your raycast, and use OnTriggerEnter to handle the jumping. You could do this in a child object if you need to (IE if you have a trigger on the player).

Hope this helps!

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

83 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

Related Questions

How to jump on only "ground" colliders 1 Answer

Player can jump on non ground hazards? 1 Answer

inconstant ground check on two identical platforms 1 Answer

Player can jump on non ground items 1 Answer

Player does not jump when running at the edge of a ledge (How to add jump tolerance?),Player Does not jump when at the edge of a ledge 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