- Home /
Question by
NMatanski · Jan 27, 2020 at 10:49 AM ·
rigidbody2dvelocityraycasthit2d
Modifying a kinematic rigidbody2D.velocity makes player to go through the wall
I've added a Dash mechanic to the 2D platformer game I'm making. The player has a Kinematic rigidbody so I'm using the following line:
rigidBody2D.velocity = new Vector2((IsFacingRight ? Vector2.right : Vector2.left).x * dashSpeed, 0);
It's working pretty nice. It's inside a coroutine, managing how fast it's going to be, managing the cooldown time. But the player is going through walls. I tried to do this in FixedUpdate() and in Update() but the problem is appearing in both of the methods. I use raycast (8 rays horizontally going from the player) to detect collisions and it's working really good when running/sprinting, but when dashing with boosted rigidbody2D.velocity it goes through walls.
Comment