Hi,
My objects position has a Mesh Collider attached to it. What the below code is doing, is only taking into account "1" of the game objects. I need it to consider the many game objects (that have a Mesh Collider attached it), within the Players distance from them.
`if (Vector3.Distance(lastPosition, objectPosition) < 125f)
{// if we are within the distance of the objectlastPosition = transform.position; Debug.Log("Hello"); if (Vector3.Distance(oldPosition, transform.position) < 0.01f) { // if we move pause_varaible = true; } if (! pause_varaible) { // increment varaible pause_varaible = false; } // else the above is greater. oldPosition = transform.position; } else if (Vector3.Distance(lastPosition, objectPosition) > 250f) { lastPosition = transform.position; if (Vector3.Distance(oldPosition, transform.position) < 0.01f) { pause_varaible = true; //Debug.Log("Stopped Moving"); } else if (Vector3.Distance(oldPosition, transform.position) > 0.01f) { pause_varaible = false; } if (! pause_varaible) { // decrement varaible } oldPosition = transform.position; }
`
Its not an "ideal" peice of code for what I want to happen, so I was wondering if I could simply it with:
MeshCollider [] mCol = (MeshCollider []) Physics.OverlapShere(transform.position, 125f);
To get all Game Objects that have a MeshCollider within the Players Distance from the Game Objects?