Quantcast
Channel: Answers by "brunopava"
Viewing all articles
Browse latest Browse all 64

Answer by brunopava

$
0
0
You could use a enum to list the states of your npc. Like: idle, chase, attack Check for the transitions in an Update() function and take the correct action. This aproach is called Finite State Machine (FSM). A pseudo code should look like: enum States{ idle, chase, attack } States currentState; Update() { switch(currentState) { case(States.idle): BeIdle(); break; case(States.chase): Chase(); break; case(States.attack): Attack(); break; } } Also don't forget to make the transitions and change the value of "currentState" to the next state.

Viewing all articles
Browse latest Browse all 64

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>