Pagina's

Monday 2 September 2019

Chasing goats

The gathering mechanics are nearly finished. I have a system to send a worker to a resource.  Once it arrives there, he'll start carrying resources from the thing until it is depleted or the worker reaches his carrying capacity.  He returns the stuff to a building and goes back to the resource to continue gathering or find another resource of the same kind. If there are no resources available within a certain range, the worker will look for other objects that become resources when they die and will attack that.

Every worldobject has a slot for a prefab to instantiate when its health goes to zero. For instance,  our inevitable goat is a unit, much like a worker, but when it dies, it turns into a source for food. While that could be done in many different ways,  in Holocene,  it's done by destroying the goat object and replacing it by a dead goat one.

Anyway,  when the worker has been gathering food and the source is depleted,  he may start chasing goats to kill them and get access to the food. For that, I made the chase state in my state machine.  Chasing is actually mostly the same as walking,  but with two main differences.

Firstly, chasing updates the destination all the time. If you walk to an object and the object moves away, you still walk to the spot where the object used to be.  Chasing will update the position of the target and change the direction accordingly.

Secondly,  chasing might result in fighting. In fact, that is the aim of it all. When the target gets inside a certain range,  the unit might start a range attack. If it gets closer there'll be melee fighting.  Of course this needs fine tuning,  but this is what it will probably be like.


No comments:

Post a Comment