public virtual void SetAI_Input(Ai_Input _ai_Input) { if (_ai_Input != null) { ai_Input = _ai_Input; } }
//check if grounded #region Ground Check private void OnCollisionStay(Collision collision) { foreach (ContactPoint p in collision.contacts) { Vector3 curve = transform.position + (Vector3.up * movement.groudCheckMod); Debug.DrawLine(curve, p.point, Color.blue, 0.5f); Vector3 dir = curve - p.point; if (dir.y > 0f) { if (isGrounded != true) { Ai_Input aiInput = GetComponent <Ai_Input>(); if (aiInput != null && input == aiInput) { NavMeshAgent agent = GetComponent <NavMeshAgent>(); Vector3 destination = agent.destination; agent.Warp(transform.position); //agent.SetDestination(transform.position); agent.SetDestination(destination); } } isGrounded = true; } } }
public void Awake() { currentState = null; ai_Input = GetComponent <Ai_Input>(); _fsmStates = new Dictionary <FSMStateType, AbstractFSMState>(); navMeshAgent = this.GetComponent <NavMeshAgent>(); npc = this.GetComponent <NPC>(); navMeshAgent.updatePosition = false; navMeshAgent.updateRotation = false; foreach (AbstractFSMState state in _validStates) { _fsmStates.Add(state.StateType, state); } }
public void InitializeState(FiniteStateMachine fsm, NPC npc, NavMeshAgent navMeshAgent, Ai_Input ai_Input) { SetExecutingFSM(fsm); SetExecutingNPC(npc); SetNavMeshAgent(navMeshAgent); SetAI_Input(ai_Input); }