Godot Version
4.3
Question
Hello everyone,
I’m currently working on a platformer game using Godot 4.3 and I’ve encountered an issue with player collisions that I haven’t been able to resolve. I’d appreciate any help or suggestions you might have.
Problem Description: In my game, there’s a platform that breaks when the player collides with it at high speed. To implement this, I calculate collisions using get_slide_collision_count and get_slide_collision. When the player collides with the block, I check if the player is running. If they are, the block is destroyed. However, the player should destroy the block and pass through it. Instead, the player collides with the block and is pushed back, even though the block is destroyed.
Attempts to Solve the Issue
Using move_and_collide with test_only = true: I attempted to use move_and_collide with test_only = true to detect collisions without moving the player. However, this only returns the first collision, which fails when the player collides with both a block and the ground simultaneously.
Handling Multiple Collisions with move_and_slide: I tried using move_and_slide and iterating through collisions with get_slide_collision, but since get_slide_collision only returns collisions that have already occurred, it triggers the on_wall state, breaking the movement logic. Additionally, stopping the player and making them move again doesn’t seem like an optimal solution.
Using an Auxiliary Area2D: I also experimented with using an auxiliary Area2D to detect collisions. This method worked, but since Area2D isn’t synchronized with the physics, it had to be significantly larger to detect collisions before the player collided with the RigidBody2D. Determining the ideal size for the Area2D has proven challenging and could lead to incorrect results if not sized perfectly.
At this point, I’m running out of ideas on how to solve this problem effectively. If anyone has encountered a similar issue or has suggestions on how to approach this, I’d greatly appreciate your input.
Thank you in advance for your help!