This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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?

in Engine by (12 points)

1 Answer

+1 vote

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

by (194 points)

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!

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.