- Home /
How to check Hypothetical Collisions in 2D
Hey guys - I'm coming in from Game Maker, and having some friction making the transition.
In Game Maker, you have a function called place_meeting(x,y,object) that returns true if the game object calling it WOULD collide with the argument object at the specified argument coordinates.
This was great for ensuring that stuff wouldn't get stuck into walls.
For example:
if (place_meeting(x+vX,y,object) {
//Increment x until place_meeting(x+1,y,object) - will push the object right up to another without mashing them into one another
}
Is there a similar function in Unity/Unity2D? I'm doing some reading on the Collision events, but it seems like those only handle collision that happen THAT frame, rather than hypothetical collisions.
Any help appreciated.
Answer by FoodFish · Oct 27, 2016 at 08:32 PM
Did you ever find out? I'm wondering the same thing.
The only thing I can think of is to try a raycast of some kind. And as long as everything is set up correctly, I haven't experienced much issue with the 2D collision. If you're literally worried about objects getting stuck together, this post helped me:
http://answers.unity3d.com/questions/794668/2d-character-controller-getting-stuck-on-walls.html
Your answer
Follow this Question
Related Questions
Destroy a gameObject in the scene if instantiate the same gameObject 0 Answers
Death Counter dont work when changing scenes 2 Answers
I Can't Jump, And If I Remove if(isGrounded) I Can Do More Then 10 Jumps IN The Air 1 Answer
Moving a player smoothly without breaking collisions? 2 Answers
How to store remaining durability of tiles? Tilemap 0 Answers