- Home /
Rigidbody2D is kind of flying instead of falling when the child box is colliding
Hi everyone,
I got a strange issue, everything is in the title, but i'll add some details :
I'm making a 2D side scroller game, the player can move on X and Y axes like in Castle Crashers. So the player has 2 objects : "Body" as parent which contains the Rigidbody2D and a BoxCollider2D, and "Feet" as child of "Body" which contains only a BoxCollider2D, which collides with some walls as you can see here :
When i press the jump key, the Y position of the "Feet" is stored, and a force is applied to the Rigidbody2D. During the jump, i set the "Feet" Y position with the one stored. On a normal behaviour it works fine, but if i go against a wall (as shown on the screen), during the jump, when the Body is supposed to go down, he flies (the body keeps a velocity of 0).
I guess the "Feet" collision breaks the "Body" Rigidbody2D stuff (i tried by adding a OnCollisionStay2D on the "Feet" object and it's returing true each frame).
Does someone knows how i can avoid that ? One solution is to make a "teleport" of 0.01f on top of the wall, but i would prefer to avoid this solution.
PS : i already have a Physics2D Material with 0 as friction on the player and the wall
PS2 : sorry for my bad english :/
Answer by Driseus · Sep 16, 2015 at 05:16 PM
make the feet collider trigger pls!!!
I don't understand, if i set the feet collider on trigger it will not collide with the wall anymore right ? The wall is there in order to avoid the player of going out of the screen (when the camera isn't moving).
the body collider will collide with it thats enough.
I could do that yes, but i need a collider which always stay on the player feet, even while he's jumping, in order to detect collisions with small obstacles on the level, depending on the feet position.