New answers tagged

0

If you don't want collisions to be able to push your objects, you can make them Kinematic (Under Rigidbody 2D -> Body Type -> Kinematic) This tells the Physics engine "I will take responsibility for this object's movement, including dealing with collisions, so you don't have to push this object around to solve penetration" The trick is that then you ...


0

Looking at the code you referenced in your link, and the code you wrote, I'm not sure how you came up with that to be honest... Especially the time variable which doesn't exist in the example you posted and what you do to calculate it isn't in the example you posted either... So I'm wondering whether I'm understanding your question correctly or whether you ...


1

It doesn't matter that much for collisions with static objects. It gets more relevant when you have collisions between moving entities. Personally I prefer to check first and move when the destination is valid, because it prevents two problems: You don't have to remember where the entity moved from You never have an entity in an illegal position


0

Your goal is to prevent them from going into each other, which means once you detect a collision they shouldn't go toward each other. I assume the sumos are circles. I wrote some pseudo code to show how to do it: # We compute how much one moves relative to the other. velocity = velocity_B - velocity_A; # If the sumos are circles the normal is the ...


0

The first point to note, is that an axis aligned bounding box(AABB) is a special case of the Orientated Bounding box(OBB), thus, it is possible to treat AABB as OBB. Secondly, you will need a robust and reliable narrow phase collision detection algorithm. I recommend starting with Separating Axis Theorem, or SAT for short. It's fast-ish, and easy to ...


0

Hi sorry I'd prefer to comment but I don't have enough reputation on this account. Your code actually looks very clean by the way, I wish I could see the rest of your code. I'm assuming your 'checkCollision' method is returning false. If this is the case, my guess is it has something to do with your call of the intersection function. Usually intersection ...


0

To detect collisions between a circle and an AABB, you should find the closest point from the AABB to the circle. You can run the below code snippet and try to move the purple point which represents the AABB center to watch the position of the closest point. <iframe src="https://www.desmos.com/calculator/u32th8uhli?embed" width="500px" height="500px" ...


1

I managed to solve collisions problem by splitting the collision handling into horizontal and vertical components, one at a time. The implemented idea is: Move player on horizontal axis. Check for collisions. Solve collision on horizontal axis. Move player on vertical axis. Check for collisions. Solve collisions on vertical axis. This system does not ...


-1

What you need to do is to move the player "to" the collision when one is detected using raycasting before actually moving the player. You should raycast from the leading sides of the player (if velocity.x > 0, raycast from the right edge of the player, if velocity.y < 0, raycast from the bottom, etc.) multiple times along those edges. If a collision ...


0

I would define a class for each type of room shape. For rooms that are quadrilaterals or circles, it is easy to define those shapes and test if a given point is within them. If the shapes of your rooms are anything else, it may be easier to create a Polygon Collider and test Collider2D.OverlapPoint using that collider and the position of the unit: public ...


Top 50 recent answers are included