I’m sorry to bother you with that but I can’t seem to get this bug fixed…
To better have a look and because a picture is often worth a thousand words, here is a little video : https://streamable.com/cnsii1
To give you more details : the red and orange square have platform behavior
My character is setup with “states” and here, the RUN state alternates with the FALL state when the character collides with a wall smaller or equal to 2 squares.
Another info (I don’t know if it’s relevant) : the character and the ground/wall are on 2 different layers…
I thought about the collision masks, I tried to fidle with them but didn’t get any result…I don’t really know what the rule of thumb is when creating custom collision masks (except for the convex constraint).
It’s the collision boxes that are causing the problem. The collision box for the run animation is from feet to head. For the fall animation, it’s from waist to head. So when the character is in fall mode, it does so until the hui box collides with the red square.
In this screen shot, you can clearly see the collision box outline on the character, and it’s still a wee gap to the red platform (indicated by the red arrow I included):
The easiest fix is to change the fall animation hit box to be from feet to head, so it’s the same as the run animation hit bx
I tried what you rightly suggested but it doesn’t really seem to work…Here is a video which I slowed down where you can see that the character goes through the different states RUN → FALL → IDLE when I run against the wall.
It’s the base of the hit box that matters. That’s how the platform behavior knows the player is on the ground. If they don’t match it causes 2 problems. First, it will drop and then if the other hit box is inside the platform it will force the objects apart, sometimes violently with a random force.
You can align the collision around the image just make sure the hit box and origin points align.
Since there’s events for isFalling it doesn’t know the difference between an intentional fall and one caused by the changing hit boxes or origin points.
Thanks @Keith_1357 ! I’m not sure I understood everything you said, especially in the first paragraph! What do you mean when you say : “If they don’t match’”? When you say “they” , do you mean the “ground Collision mask” and the “Object collision mask”?
Oh yeah…Didn’t think about the points…I didn’t modify them…I should give that a try tomorrow!
Thanks again for the explanations!
By the way : is there some broad guidelines I should follow to set up those collision masks?
@Keith_1357 Sorry, a follow-up question : when you say : “just make sure the hit box and origin points align”. What do you mean?
Must all the animations of a character have the same Origin point? (I guess so…)
Or do you mean, within the same animation, the origin point must stay the same but can change across the different animations?
Aligning the bottom edge perfectly only really matters with things like the platform behavior because the behavior determines the placement of the object based on the mask and the points.
The origin point is more like an offset. Moving the point moves the image in relationship to the the X, Y. The image will move up, down, left and right based on the point along with the mask.
The collisions box or hit box or mask or whatever you want to call is used to detect collision. It’s normally roughly the same size as the image but there’s nothing saying it can’t be larger than the drawn part or smaller.
The main thing is the combination of the point and the collision mask needs to match on the bottom otherwise when you switch frames or animations it would change the position of the collision mask.
It’s easier to keep everything aligned if they share the same point and image size. By image size I mean the file or canvas size not the actual image or pixels. For a platform game, you just want to draw everything along the bottom of the canvas. Any empty part should be on the top. That way you can align the bottom edge and if needed move the top points.
@Keith_1357 Thank you very much for the detailed clarifications! It all makes sense and I’ll have to come back to your post a few times to fully grasp what you’re saying. I’ll meditate on that!
Anyways, as regards to my “bug”, I realigned the Origin points of the animations of my character. They are now all at the same place on all the animations and as far as I can tell, the bug we could see on the video I posted no longer exist.