|
|
|
|
Reply From: |
mateusak |
Okay, so it seems there’s this awesome collision shape named RayCast2D which prevents this from happening. It’s very simple, put a RayCast2D collision shape on the feet of your player and you’re set.
This ended my 3 day struggle to find a solution to this problem. Thank you!
Taylor Hansen | 2017-05-05 03:09
It could help if you included the player.tscn file. Plus this is mostly for rigid bodies which handle all that physics and gravity stuff for you.
Taylor Hansen | 2017-05-09 00:25
Hi Taylor,
thank you for your time. Here’s the tscn
inkmotor | 2017-05-09 00:29
It looks like you didn’t actually do what was suggested here
Taylor Hansen | 2017-05-09 00:33
I did, but it still didn’t work so I took it off. Just to be clear, the raycast goes above the collisionShape2D in the tree right?
inkmotor | 2017-05-09 00:36
The tree order doesn’t matter, and it’s a CollisionShape2D with a RayShape2D set as its shape, not an actual RayCast2D node.
Taylor Hansen | 2017-05-09 00:37
Ahhhhhhhh! THAT’S the part I was missing. Thanks!
inkmotor | 2017-05-09 00:39
You need both the RayShape2D and the RectangleShape2D (2 CollisionShape2D nodes as a child of your KinematicBody2D, which could probably be a RigidBody2D).
Taylor Hansen | 2017-05-09 00:46
Ok thank you very much
inkmotor | 2017-05-09 00:47
The collision_capsule
should have a rectangle, not a capsule. Also I would recommend making the raycastshape a length of 1 and using the inspector to perfectly position it such that it’s right in the bottom center, protruding out of the bottom by a pixel. Here’s a rough description of what you should have, assuming the scale of each node is (1, 1):
root (RigidBody2D)
sprite (Sprite2D)
hitbox (CollisionShape2D)
shape = RectangleShape2D
extents = (32, 32)
pos = (0, 0)
bottom (CollisionShape2D)
shape = RayShape2D
length = 1
pos = (0, 32)
Taylor Hansen | 2017-05-09 01:30
Dude, thank you so much, I very much appreciate your help. I will try that this afternoon, cheers!
inkmotor | 2017-05-09 02:27