Skip to content

Detecting "ground" #68

Answered by Genbox
ambs asked this question in Q&A
May 1, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

There are several ways of doing this.

Method 1: You can get the normal of the collision between two shapes. You register the OnCollision event on a body, and in the event method you can use the Manifold property to get the normal. If the normal is 1 (or -1) on the Y axis, then the collision is on the ground. See lines 106 and 215 in this example: https://gist.github.com/Genbox/9b3d2232b6bc22b6c8815487d086c769

Method 2: You can register OnCollision like Method 1 and check if the body in the collision is the ground body. Example here: https://gist.github.com/Genbox/9737d1155efcdd00c9858cf7a492323e

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ambs
Comment options

Answer selected by Genbox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants