- Home /
How do you detect if two specific objects are touching each other without collision.
My game's bird's eye view and i want to have a certain game object that gives input when the player's on top of it
you can implement your own collision detection system or use rycast for this.
Answer by James_BadAlchemy · Feb 12, 2019 at 01:11 AM
Why not use collision?
You -could- shoot a raycast down and check to see what you're hitting. This is more expensive, though.
Answer by stitchfingervideo · Feb 12, 2019 at 05:29 AM
If it's birds'-eye, just put a check in your update to see whether the player's 2D coordinates match that of your game object.
Update()
if (transform.position.x == player.transform.position.x &&
transform.position.z == player.transform.position.z)
{
//Do some thing
}
Something like that would work.
This wouldn't work very well that's just checking if it's at point, it could be 0.001 off on one axis and this wouldn't work...
Answer by Chimer0s · Feb 12, 2019 at 05:43 AM
If you don't want to use collision you could perform a distance check.
if (Vector3.Distance(player.position, other.position) <= 0.1f)
DoTheThing();
I dunno why people wouldn't just set it to isTrigger sounds like what OP wants.
because it feels like he is asking of a solution for checking collisions without unity physics, and the easiest approach for that would be rycast
I think he wants to check if his player is on top of a position, he just doesn't want it to have collision. Anyway this answer is probably the thing to do.
Your answer
Follow this Question
Related Questions
Get information on ignored collision 1 Answer
Rotate a weapon in a circle around player 1 Answer
Maintain equal physics over different UI sizes? 2 Answers
Help with 2D physics script 1 Answer
Trying to get a ball to bounce realistically in 2D. 2 Answers