/// <summary> /// Take off from ground /// </summary> /// <returns> /// Wether or not the function was successful /// </returns> public bool TakeOff() { if (CurrentFlyableState == FStatesFlyable.NotFlying) { FSMFlyable.ChangeState(FStatesFlyable.TakingOff); return(true); } return(false); }
void Landing_Update() { if (!_freefall) { Flying3DObjectComponent.ApplyVerticalThrust(false); } if (GroundProximityCheckerComponent.IsAlmostTouching()) { FSMFlyable.ChangeState(FStatesFlyable.NotFlying); } }
/// <summary> /// Land on a surface /// </summary> /// <param name="onNavMesh">Surface must be NavMesh</param> /// <param name="freefall ">Just fall down instead of gently landing</param> /// <returns> /// Wether or not the function was successful /// </returns> public bool Land(bool onNavMesh = true, bool freefall = false) { if (CurrentFlyableState != FStatesFlyable.Flying || (onNavMesh && !NavMeshAgentComponent.IsAboveNavMeshSurface())) { return(false); } _freefall = freefall; FSMFlyable.ChangeState(FStatesFlyable.Landing); return(true); }
void TakingOff_Update() { if (BotFSMLocomotionComponent.IsCloseToGround()) // .IsFarFromGround()) // { Flying3DObjectComponent.ApplyVerticalThrust(true); } else { RigidBodyComponent.Sleep(); FSMFlyable.ChangeState(FStatesFlyable.Flying); } }
protected override void OnCollisionEnter(Collision collision) { if (CurrentFlyableState == FStatesFlyable.Landing) { NavMeshHit navHit; for (int i = 0; i < collision.contacts.Length; i++) { if (NavMesh.SamplePosition(collision.contacts[i].point, out navHit, 1f, NavMesh.AllAreas)) { FSMFlyable.ChangeState(FStatesFlyable.NotFlying); break; } } } }