Player does not jump again after first jump.
In create a 2D platformer I am trying to remove wall jumping. What I have done is create two box colliders: one for my player and another for my players feet. In order to accomplish this I have two game objects: one for my player and another for my player's feet. The player contains a RigidBody2D component that is dynamic and a box collider with a zero friction material. The player's feet have just a Box Collider2D on them and I have made this game object a child of the player game object.
When i play the game the collider for the feet follows the player great. This works wonderfully. When I check the contacts in the collision component everything seems to be correct. The contact points for the playersfeet gameobject are: the Foreground collider, the Foreground rigidbody and the Player rigidbody which makes sense as its collider is touching the player collider.
The problem is that the first jump command works, the second does not. Here is the code to run the player's jump command.
if (!myPlayersFeet.IsFeetTouchingGround())
return;
The method to check if the player's feet are touching is
public bool IsFeetTouchingGround()
{
return myFeetCollider.IsTouchingLayers(LayerMask.GetMask("Foreground"));
}
When I did not have the playerfeet collider this was working fine with the IsTouchingLayers in the player script instead since it was the player collider that was being checked. Now that I have a feet collider as child to my player collider this game object needs to check for its collider so I create a public method to access it from the player object.
It works one time, then stops working. The IsTouchingLayers returns false. The collision contacts says it is in contact with the Foreground. So I'm at a loss.
Your answer
Follow this Question
Related Questions
Jumping on enemies help 0 Answers
Having Issue with Player Jumping Consistently 0 Answers
faux gravity 2d plataformer jumping doesnt work 0 Answers
Rigidbody moving on platforms 0 Answers
HELP Mecanim Character falls halfway into ground after Jump 0 Answers