void UpdateTransformParenting() { #region Update Platform Parenting //Create a downward ray Ray DownRay = new Ray(transform.position, new Vector3(0, -1, 0)); RaycastHit DownHit = new RaycastHit(); //Check what you are currently standing on if (Physics.Raycast(DownRay, out DownHit, (CharacterHeight / 2) + 1)) { FloorObject = DownHit.transform.gameObject; if (FloorObject.layer == 8) { transform.parent = FloorObject.transform; } else { transform.parent = Scr_PlayerController.inst.transform; } } #endregion #region Portal Check if (PreviousFloorObject != null && FloorObject != null) { if (UnderPlayerControl) { //If the previous floor object was not a portal if (PreviousFloorObject.GetComponent <Scr_Portal_Entity>() == null) { //And the current one is if (FloorObject.GetComponent <Scr_Portal_Entity>() != null) { if (FloorObject.GetComponent <Scr_Portal_Entity>().GetPartnerPortal() != null) { if (FloorObject.GetComponent <Scr_Portal_Entity>().IsBlocked() == false) { //Teleport the character Scr_Portal_Entity TargetPortal = FloorObject.GetComponent <Scr_Portal_Entity>().GetPartnerPortal(); Vector3 TargetPosition = TargetPortal.transform.position + new Vector3(0, CharacterHeight / 2, 0); transform.position = TargetPosition; //Make the character independant Scr_PlayerController.inst.SeperateCharacter(Scr_PlayerController.inst.GetPartyIndex(this)); } } } } } } #endregion }
public virtual void UpdateTransformParenting() { #region Update Platform Parenting //Create a downward ray Ray DownRay = new Ray(transform.position + new Vector3(0, EntityCollider.bounds.extents.y, 0), new Vector3(0, -1, 0)); RaycastHit DownHit = new RaycastHit(); //Check what you are currently standing on if (Physics.Raycast(DownRay, out DownHit, EntityCollider.bounds.extents.y + 0.1f)) { FloorObject = DownHit.transform.gameObject; if (FloorObject.layer == 8) { transform.parent = FloorObject.transform; } else { transform.parent = Scr_PlayerController.inst.transform; } } #endregion #region Portal Check if (PreviousFloorObject != null && FloorObject != null) { //If the previous floor object was not a portal if (PreviousFloorObject.GetComponent <Scr_Portal_Entity>() == null) { //And the current one is if (FloorObject.GetComponent <Scr_Portal_Entity>() != null) { if (FloorObject.GetComponent <Scr_Portal_Entity>().GetPartnerPortal() != null) { if (FloorObject.GetComponent <Scr_Portal_Entity>().IsBlocked() == false) { WaitingToTeleport = true; //Teleport the character Scr_Portal_Entity TargetPortal = FloorObject.GetComponent <Scr_Portal_Entity>().GetPartnerPortal(); Vector3 TargetPosition = TargetPortal.transform.position + new Vector3(0, -TargetPortal.EntityCollider.bounds.extents.y / 2, 0); transform.position = TargetPosition; TeleportTarget = TargetPosition; TargetPortal.LatestEntity = this.gameObject; } } } } } #endregion }