Solutions for player hitboxes?

(Using the latest version of Wick)

Hi! First time poster. I have been spending some time familiarizing myself with the editor and I must say I am very satisfied with it so far. I do have a problem, however. Currently I am working on a game for fun and I cannot really figure out a good, clean way to stop the player’s movement when the player’s hitbox (A separate clip that moves with the player’s sprite.) touches another object’s hitbox. Just learning JS this has presented itself as quite the challenge. Could anyone come up with a solution and explanation?

What have you tried so far?
I have tried a lot of things. Any solutions that involve pushing the player back did not work well for me. This is because it does not look very good and some solutions I have attempted to make that use that method have been very buggy.

Any sort of help would be greatly appreciated!

You can use hit triggers!
Use this code

if(object name.hits(other object name)){
//code to execute

1 Like

it looks like you are asking how to make objects collide, not necessarily detecting when objects touch.

I have a platformer engine here that might do what you want, if you want a platformer.

if you want top-down, watch this.

1 Like

Welcome to the forum family @Douchott

Thank you all so much! Works like a charm. I do have another question, though. Are diagonal hitboxes possible? How would collision detection work with those?

theoretically they can be done. I’ve tried but failed.

instead of comparing the player’s y position to the block’s y position (and x pos to x pos), you would need to campare the y position to both the x and y position of the block (since different places on the slope means a different y position). I tried using slope-intercept but it didn’t work, and I never tried anything since.