How to calculate the center of a rotating, moving TextureRect

I have several TextureRect objects flying about each rotating this way and that randomly.

The property global_position makes it trivial to find where they are but I cannot figure out how to calculate the center of each texture. If at least I had the position of the corners or anything like that, it would be easy. To complicate things further, these textures have random scale values.

Anyway, there is a solution to this problem (perhaps using a different type of node) but I am a Godot rookie and am stuck.

Thank you all.

you can get the scaled texture size and divide by 2 to get the center of it.

2 Likes

I tried that.

The problem is the rotation. I cannot tell where the center is because it is moving.

Can you show how its moving?

1 Like

It’s a somewhat random parabola with an additional random rotation.

It now occurs to me that perhaps adding to the TextureRect object a child node that is centered from the start will allow tracking. I’ll check.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.