コード例 #1
0
        /// <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);
        }
コード例 #2
0
 void Landing_Update()
 {
     if (!_freefall)
     {
         Flying3DObjectComponent.ApplyVerticalThrust(false);
     }
     if (GroundProximityCheckerComponent.IsAlmostTouching())
     {
         FSMFlyable.ChangeState(FStatesFlyable.NotFlying);
     }
 }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
 void TakingOff_Update()
 {
     if (BotFSMLocomotionComponent.IsCloseToGround()) // .IsFarFromGround()) //
     {
         Flying3DObjectComponent.ApplyVerticalThrust(true);
     }
     else
     {
         RigidBodyComponent.Sleep();
         FSMFlyable.ChangeState(FStatesFlyable.Flying);
     }
 }
コード例 #5
0
 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;
             }
         }
     }
 }