Sprites with modified points do not collide correctly


#1

Two sprites with default collision mask do not collide correctly.

The “Origin” and “Center” of sprite A are 0,0.
Sprite B’s “Origin” and “Center” are 128 and 128.



:arrow_down: Scene events

The results are as follows.


:pencil2: I’m using “dragable object behavior” but without it I still get the same problem.

I’m not sure if this issue is a bug.
Please let me know if there is a workaround. :pleading_face:


#2

Not modifying the center and origin lol. Why do you want to do that?


#3

Thanks for the reply.
I need to change points to flip or animate.

I want to create some animations where a sprite stretches a lot horizontally or vertically.
But I don’t want to create the maximum image size for all animations.

kusoripu

If there is no “Origin points” at the star position in this image, it will not be animated correctly.
Also, if there is no “Center points” in the star position of this image, it will not be correctly inverted.

This issue seems to occur when there is no “Center points” in the center of the image.

This image is just an example.
So, for example, I don’t need the idea of ​​making the sword in this image another sprite.

I want how collision works properly when I change points.


#4

Origin and center should never be the same point or location.

Because of how the collision system works it must know the center of the actual sprite vs the origin point. As far as I’ve seen messing with other engines like GMS and C3, this is true in all of them.

What you actually should do is make all of your sprites the same size as your largest sprite, but give the smaller sprites empty space to fill the excess.

Then you can align the origin point to be at the same spot on all of them, and the center to be at the appropriate point as needed.

You will just use a unique hitbox per animation.


#5

Thanks for the reply.

I’m sorry.
It seems that it is hard for everyone to understand the main subject.
That’s probably because my English is bad.

The swordsman’s example is an explanation of why I change “Center” and “Origin” and has nothing to do with the subject.

If I want to properly animate or flip the sprite I need to change the “Center points”.
The problem, however, is that changing the “Center points” will cause collisions to not work properly.

Check the first example. (Example of green and blue squares)
This problem occurs even with a non-animated square.

I want everyone to be aware of this issue.
And I want to solve it.

Please tell me if there is anything I can do.


#6

Thanks for the information.

I can’t seem reproduce your issue with changing center points not allowing collision correctly.

Here’s an example using platforms and platformer behaviors:

Platformer character’s points, definitely not centered:

Custom platform’s points.Also definitely not centered:

Events:

Start of scene:

After letting it run:

Are you messing with your hitboxes in some way?


#7

Thank you for verifying. @Silver-Streak
This bug is hard to find.

If you move “Center points” to the right, the collision on the left will be incorrect.
So in your example you can reproduce this problem by placing the obstacle to the left.



I assume that half of the “Center points” moved from the center will be scraped from the other side.
Therefore, if the amount of movement of “Center points” is small, you may not notice it.

2020-05-09%20120656_2

Similarly, if “Center points” is set to the upper side, the lower side collision will be inaccurate.



#8

Yeah, I’m able to reproduce this now.

Origin seems irrelevant, it’s specific to center. @Bouh do you or another person want to take a look at this?

As a workaround, I’d say make a hitbox object (separate square object that matches your “average” hitbox, put all of your controls on that, hide it at the start of scene, and then just attach your sprite object to the hitbox object as just a “graphical” overlay, basically.

Then your points on collision shouldn’t be impacted until a potential fix can be found, if possible.


#9

Thank you @Silver-Streak :blush:
Until this problem is solved I will try to make animation and inversion work only with “Origin points” without editing “Center points”.
I hope this issue is fixed.