/// <summary> /// Returns the ghost from posessing whatever it is currently haunting to its true form. /// </summary> public void EndHaunt(GameObject overrideHauntedObject = null, bool useTransition = true, float transitionDuration = .55f) { if (haunted) { // store return position so we can raycast to it and make sure we don't cross any boundaries Vector3 destination = haunted.GetReturnPosition(); Vector3 returnPos = destination; Vector3 destinationVector = destination - transform.position; RaycastHit hit; if (Physics.CapsuleCast( transform.position, transform.position + collider.height * Vector3.up, collider.radius, destinationVector, out hit, destinationVector.magnitude, hauntReturnColliders)) { returnPos = hit.point - destinationVector.normalized * collider.radius * 1.1f; } transform.position = GhostTools.GroundPoint(returnPos); if (useTransition && GhostTools.SafeToInstantiate(gameObject)) { GameObject hauntedObject = overrideHauntedObject ? overrideHauntedObject : haunted.gameObject; SpawnTransitionObject(transform.position, hauntedObject, transitionDuration); } haunted.OnUnHaunted(); } playMaker.FsmVariables.GetFsmFloat("transitionDuration").Value = transitionDuration + hauntTransitionOffset.Value; playMaker.SendEvent("endHaunt"); haunted = null; burningCandles.Value = 0; }
void OnTriggerExit(Collider other) { Hauntable hauntable = other.GetComponent <Hauntable>(); if (!hauntable) { return; } }
public void BeginHaunt(Hauntable newHaunted) { ResetHauntTrigger(); haunted = newHaunted; playMaker.SendEvent("haunt"); newHaunted.haunter = this; newHaunted.AttemptHaunt(this); }
void OnTriggerEnter(Collider other) { Hauntable hauntable = other.GetComponent <Hauntable>(); if (!hauntable) { return; } if (!hauntable.enabled) { return; } haunter.BeginHaunt(hauntable); }
public void MigrateHaunt(Hauntable newHauntable) { BeginHaunt(newHauntable); }