Incorrect Transform Position Origin on CollisionPolygon2D

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

I’m having an issue with the position of a CollisionPolygon2D generated with Create CollisionPolygon2D Sibling where the origin [0, 0] isn’t actually centred on the sprite itself.

I need to flip the CollisionPolygon2D to align with the animation as it’s animated, but because the transformation doesn’t occur centred it throws the CollsionPolygon2D flipped around the incorrect origin, causing it to be wildly out of place.

CollisionPolygon2D at origin 0,0
Flipped with default origin 0,0

However when I move it manually to be centred on the Sprite, it accounts for that x, y translation and also ends up being wildly inaccurate.

CollisionPolygon2D when manually placed on Sprite
Flipped with manual origin

Is there:
a) a way to reset the origin of a CollisionPolygon2D?
or
b) a way to generate collision shapes and align those with a sprite sheet?

:bust_in_silhouette: Reply From: Jorge

Hi,
are you setting up the values on the main scene of instanced ?
try in the main scene of the player set the x,y in 0,0 add the collision shape at 0,0 and create the collision polygon there, should be not problem after that.

good luck

Sorry, I’m not sure I understand your question.

Here’s the scene tree:
enter image description here

The x, y on the main scene is set to 0, as well as the collision shape. The collision shape is generated by Godot.

Thanks for your reply!

CrumbThief | 2020-07-08 21:45

Hi,
the question is :

Do you have the player create in a separate scene? and then instanced on the Level scene?

you need to check this values on the player scene and don’t edit any values of the player on the Level scene.

and if the player is on the level scene you didn’t created its values and unique… you should not change the values there.

Set everything to x = 0, y = 0
I hope it makes sense.

good luck

Jorge | 2020-07-08 22:08