Advertisement
Guest User

spawnPosIsLegal(Vector3 pos)

a guest
Dec 24th, 2014
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. ///Check to make sure the object will not spawn on top of the player or another spawned object.
  2. private bool spawnPosIsLegal(Vector3 pos) {
  3.     RaycastHit hit;
  4.     if (Physics.Raycast(pos, Vector3.down, out hit) && hit.transform.CompareTag("Player"))
  5.         return false;
  6.     string hitName = hit.transform.name.Replace("(Clone)", "");
  7.     for (int i = 0; i < objectsToSpawn.Length; ++i) { //Make sure not to spawn on top of a spawnable object
  8.         if (hitName == objectsToSpawn[i].name)
  9.             return false;
  10.     }
  11.     return true;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement