Can I setup CollisionShape level collision management ?

AnthoJackAnthoJack Posts: 12Member

For my project, I wanted to recreate the effect that I've seen on some games like Streets of Rage where going up simulates depth. For that, I wanted to have mutliple CollisionShapes (Feet and Body for now) so that the feet collide with the borders I set up and the Body can be used for other collisions. The problem is, I've only now realised that the collision layers are managed only in the KinematicBody2D node

I want only the feet's CollisionShape2D to cause a collision with the up and down borders I've setup but right now, the body's CS2D collides too and my character cannot go as high as I'd want him to go.

Is there a way to simply and "cleanly" do that ? If not, what's the solution ?


Tags :

Answers

  • vinpogovinpogo Posts: 33Member

    A workaround to that problem: you could replace the bodies collisionShape with an Area2D.
    The Area2D should give you the same capabilties as a collisionshape

  • AnthoJackAnthoJack Posts: 12Member

    @vinpogo said:
    A workaround to that problem: you could replace the bodies collisionShape with an Area2D.
    The Area2D should give you the same capabilties as a collisionshape

    I thought about doing that but it would prevent me from using the "move_and_collide" function (I think). Also it seems weird that the devs would go the extra mile, creating all physics bodies and not plan for this use case which makes the KinematicBody2D very limited in its use

    I'll use this technique if I really have to but I'd really like to have a more proper way of doing what I want

  • vinpogovinpogo Posts: 33Member

    i dont know how your game works, but from my perspective it might actually not be a bad solution.
    To me it makes sense that you block player movement when the feets collisionShape is colliding.
    On the other hand i think it also makes sense that the bodies collisionShape does not block movement, but rather check if any interactive objects are overlapping -> Area2D.get_overlapping_bodies(). This means you would not benefit from hooking into the move_and_collide function to check for interactive objects.

    But again i cannot tell if this makes sense in the context of your game

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file