Pagina's

Wednesday 5 June 2019

Giving tasks

So yesterday, I did some groundwork for the behaviour of units in Holocene. I decided to go with a Finite State Machine that keeps track of two things the unit is doing.  There is a state and there is a task.

The state keeps track of what the unit is doing, like moving, fighting and gathering resources. The task is about what the unit is trying to achieve. For instance we have this amazing cylinder tree to cut for wood.


By sending the unit to the object, the system understands it will be a gathering operation, because the object has a Resource component. The player will then get the task of gathering,  related to this specific object. 

Gathering will then mean the unit has to first go there, so the state will be set to moving. Then, when the unit has reached its destination (which will have different meanings depending on the type of movement) the state will go to gathering untill some threshold is reached. Next, the state will be moving, because the unit will need to drop off the resources at a certain place and then the circle starts over again. 

I'm sure there'll be some complications,  but I think that this FSM should be the basics for the units and their behaviours. I'll first focus on the player's units.  If I do this well, getting the enemy to work should be about getting the states and tasks to change, which will be complex in its own right. 

I do however intend to keep these AI parts separate.  There's the way a unit deals with a specific task. That's up to the unit. Giving tasks is the player's job. That's for later.

No comments:

Post a Comment