New answers tagged

0

The simple solution is to add a bool property to the door indicating if its open or not. Then you simply check: if(ohter.gameObject.CompareTag("Player") && Door.isClosed) { //Do logic here } You can even set the isClosed to false when the open animation has finished using a Animation Event.


1

I think you need some documentation about collisions. It seems you want to check the collision between 2 hitbox on a 2D game: if (rect1.x < rect2.x + rect2.width && rect1.x + rect1.width > rect2.x && rect1.y < rect2.y + rect2.height && rect1.height + rect1.y > rect2.y) { // collision detected! } But you're ...


0

It's not clear what you are trying to achieve, but changing the < operators to <= might be a step in the right direction.


0

Your issue seems to be that you are only checking a single tile if your player is 32 or less pixels wide. That obviously does not work, because your player is taller than one tile. Hence, you need to remove the first easy-oit as it breaks the detection, and simply just rely on the looping method.


2

When you have multiple collisions if you rectify your collisions from closest to farthest away from the center of each rectangle involved, you will not have the issue of "hanging." 1) Find all the colliding rectangles 2) If there are more than one (depending on your use case this can be frequent or infrequent), find the closest. 3) Resolve collisions ...



Top 50 recent answers are included