Reputation: 1
The AnimatedSprite2d is changing horizontally but the CollusionShape2d isn't, here is the code:
if direction == 1:
$AnimatedSprite2D.scale.x = 1
$CollisionShape2D.scale.x = 1
if direction == -1:
$AnimatedSprite2D.scale.x = -1
$CollisionShape2D.scale.x = -1
How can I fix it?
I tried changing it to flip.h but it threw me an error that it was out of scope, also my collusion shape is a rectangle.
Upvotes: 0
Views: 228
Reputation: 131
It is generally a bad idea to change the scale of physics objects, and CollisionShape2D
is no exception.
To get around this, try changing how you approach the problem to avoid resizing the collision shape at runtime. Some ways you could accomplish this are:
Hopefully one of these solutions work for you!
Upvotes: 0