Quantcast
Channel: Questions in topic: "physics 2d"
Viewing all articles
Browse latest Browse all 132

Rigidbody2D is kind of flying instead of falling when the child box is colliding

$
0
0
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 : ![alt text][1] 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 :/ [1]: /storage/temp/54440-bug-physique.png

Viewing all articles
Browse latest Browse all 132

Trending Articles