Question about AnimatedSprite with Collisionshape2d

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By truedat

hello there,
i have a character that is an AnimatedSprite which has my animations in it. idle/walk/jump and duck. i have set the collisionShape rectangle to it. but when i go to my animation duck the collisionshape doesnt fit the animation. it fits perfectly for idle/walk/jump but when i duck the collisionshape doesnt duck :wink: hope you understand my problem here… how can i change the collisionshape for that specific animation in my animatedSprite to avoid for example a bullet by ducking in the game?
any help would be appreciated

:bust_in_silhouette: Reply From: Scavex

The part of you code where your character ducks, just add a code of line there to change the collision shape :

$CollisionShape2D.scale.x = Your value 
$CollisionShape2D.scale.y = Your Value

You can use the Inspector tab which is the window on your right hand side where you will see Transform option under which there will be Scale in x and y provided. Tweak the shape using those and once you get a shape that fits well with your character when he is ducking, use the above code to put the values of x and y.

hey scavex, thanks alot for your fast reply and help !!. kool, i will try this out asap…

truedat | 2020-09-05 01:51