- Home /
Question by
madmart · Apr 09, 2014 at 04:52 AM ·
raycastsimultaneous
How do I differentiate between simultaneous collisions?
I want a raycast to know when two distinct collisions both occur. But Raycast seems to return only one collision.
I tried having the raycast move a collider, and using OnTriggerEnter with that collider to check for the multiple collisions, but it can't distinguish them either.
here's the script I'm working with:
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast (ray, hit, 100.0)){
if (hit.transform.tag == "Tile")
cursor.transform.position = hit.transform.position; //adjusts cursor to current tile height
validMove = (hit.transform.tag == "Valid Move") ? true : false;
}
When I move mouse over just a tile it works fine, adjusting cursor position to match the tile's. And when I move mouse over a trigger marked "Valid Move" it returns true, as it's supposed to. But when both triggers are present, the raycast only detects one of them.
Comment