/// <summary> /// Initialize the BotPartWanders used by BotFlyable /// </summary> protected override bool InitBotWander() { if (!base.InitBotWander()) { return(false); } BotWanderNavMeshComponent = GetComponent <BotPartWanderNavMesh>(); BotWanderManagerComponent.Initialize(BotWanderNavMeshComponent); return(true); }
/// <summary> /// Initialize the BotPartWanders used by BotFlyable /// </summary> protected override bool InitBotWander() { if (!base.InitBotWander()) { return(false); } BotWanderFlyingComponent = GetComponent <BotPartWanderFlying>(); BotWanderNavMeshComponent = GetComponent <BotPartWanderNavMesh>(); if (CurrentFlyableState != FStatesFlyable.NotFlying) { BotWanderManagerComponent.Initialize(BotWanderFlyingComponent); } else { BotWanderManagerComponent.Initialize(BotWanderNavMeshComponent); } return(true); }
/// <summary> /// Toggle between flight with physics and NavMeshAgent /// </summary> private void ToggleFlight(bool on) { if (on) { RigidBodyComponent.constraints = RigidbodyConstraints.None; CurrentLocomotionType = BotLogicFlyingRef; BotWanderManagerComponent?.SetCurrentBotWander(BotWanderFlyingComponent); } else { RigidBodyComponent.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ | RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ; RigidBodyComponent.velocity = Vector3.zero; transform.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0); CurrentLocomotionType = BotLogicNavMeshRef; BotWanderManagerComponent?.SetCurrentBotWander(BotWanderNavMeshComponent); } NavMeshAgentComponent.enabled = !on; Flying3DObjectComponent.enabled = on; }
void Landing_Enter() { BotWanderManagerComponent?.StopWandering(); Flying3DObjectComponent.HoverWhenIdle = false; }
void TakingOff_Enter() { BotWanderManagerComponent?.StopWandering(); Flying3DObjectComponent.HoverWhenIdle = true; ToggleFlight(true); }