private void snatch() { if (Vector3.Distance(transform.position, citizenGrabbed.transform.position) < maxSnatchRadius) { playerRenderer = GetComponent <Renderer>(); playerRenderer.sharedMaterial = citizenGrabbed.GetComponent <Renderer>().sharedMaterial; Debug.Log("Your current material is: " + playerRenderer.sharedMaterial + "\nThe index of the citizen you killed was: " + closestCitizenIndex); Debug.Log("Your position at the time was: " + transform.position); citizenGrabbedWander.pausePath(); citizenGrabbedWander.snatched(); citizenGrabbedWander.enabled = false; citizenGrabbed.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; citizenGrabbed.GetComponent <Rigidbody>().AddExplosionForce(3, transform.position, 4, 0, ForceMode.Impulse); //Basically: citizen[target].avoidPlayer.doIKnowPlayerFace(); citizenGenerator.getCitizenAt(citizenGenerator.getTargetNum()).GetComponent <AvoidPlayer>().doIKnowPlayerFace(false); missedSnatch = false; kill(); } else { Debug.Log("Your distance to the nearest citizen was: " + Vector3.Distance(transform.position, citizenGrabbed.transform.position) + " and the minimum distance was: " + maxSnatchRadius); citizenGrabbed = null; missedSnatch = true; } }
void OnDestroy() { GenerateCitizens generateCitizensScript = gameObject.transform.parent.GetComponent <GenerateCitizens>(); generateCitizensScript.getCitizenAt(generateCitizensScript.getTargetNum()).GetComponent <AvoidPlayer>().doIKnowPlayerFace(true); }