Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 void Landing_Update()
 {
     if (!_freefall)
     {
         Flying3DObjectComponent.ApplyVerticalThrust(false);
     }
     if (GroundProximityCheckerComponent.IsAlmostTouching())
     {
         FSMFlyable.ChangeState(FStatesFlyable.NotFlying);
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
 void TakingOff_Update()
 {
     if (BotFSMLocomotionComponent.IsCloseToGround()) // .IsFarFromGround()) //
     {
         Flying3DObjectComponent.ApplyVerticalThrust(true);
     }
     else
     {
         RigidBodyComponent.Sleep();
         FSMFlyable.ChangeState(FStatesFlyable.Flying);
     }
 }
Ejemplo n.º 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;
             }
         }
     }
 }