Hello,
I have a CollisionShape2D attached to a KinematicBody2D. I want to change this collision shape when a certain state is entered. I looked around online, and it seems most people used an AnimationPlayer for this.
Here is my current setup:
func get_hitbox_from_state() -> void:
match current_state:
STATES.DJUMP:
$collision_changer.play("djump_collision")
_:
if prev_state == STATES.DJUMP:
$collision_changer.play_backwards("djump_collision")
And here is the AnimationPlayer setup (with snap 0.001s)
https://imgur.com/a/MOdevJx
All the AnimationPlayer does is tween from the default CollisionShape shape/position to the one I want when the state STATES.DJUMP is entered.
But now, when I try landing on something in game, I instantly clip through it. Here is a GIF of what happens:
https://imgur.com/a/v8HLIj5
I have tried having two collision shapes, one for default, one for STATES.DJUMP, and disabling one or the other depending on the state. I have also tried changing the CollisionShape's shape and position manually like so:
func get_hitbox_from_state() -> void:
match current_state:
STATES.DJUMP:
$collision_box.shape.extents = Vector2(20, 20)
$collision_box.position.y = -20
_:
$collision_box.shape.extents = Vector2(26.217, 66.251)
$collision_box.position.y = 3.287
But nothing changes. Has anyone experienced this before or have a different solution for changing a CollisionShape on the fly?
I would be happy to answer any questions. Thank you in advance.