public void DetachActor() { if(isPossessing) { animalController.enabled = false; animalController = null; } isFollowing = false; isPossessing = false; possessedCreature = null; }
void CheckForCreature() { RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up, 0.5f, faunaMask.value); potentialFauna = gameObject; if(hit.transform != null) potentialFauna = hit.transform.gameObject; if(!isPossessing && !isFollowing && Input.GetKey (KeyCode.Q) && potentialFauna.CompareTag("Fauna")) { possessedCreature = potentialFauna; stateMachine = possessedCreature.GetComponent<AnimalStateMachine>(); animalController = possessedCreature.GetComponent<PossesionController>(); animalController.enabled = true; isPossessing = true; } if(!isPossessing && !isFollowing && Input.GetKey (KeyCode.W) && potentialFauna.CompareTag("Fauna")) { possessedCreature = potentialFauna; transform.position = potentialFauna.transform.position; renderer.enabled = false; isFollowing = true; } }