Pagina's

Saturday 20 July 2019

The action and the goat

So, back from my two weeks holiday to Santorini with my wife and back to programming in another week of before the office seems to need me again. I made two things in Holocene work. One is a UI thing and the other is a game mechanic.

The UI thing is about getting tooltips for when the mouse cursor hovers over an object or a UI element. For now I wanted two kinds of tooltips to be possible: Object tooltips and action tooltips. Object tooltips are actually pretty straightforward and they were easy to implement. Whenever the mouse hovers over an object, I use the same system that helps me detect objects to be able to select them by clicking. That system will trigger a little GUI panel with some information about the object.

The second thing was more difficult. Actions are not physical things, just GUI elements. This means that I could not use the system I use for detecting objects. I tried to use events on the button for running the actions, but that did not work, because the buttons are rebuilt all the time, making the tooltip flash on and off, because it detects there's nothing that we point to. This took some time to fix, because I needed to work with an unfamiliar concept: a graphics raycast. How could I know that existed?

With a graphics raycast, I detect there is a couple of UI elements below the mouse pointer. In that list, I find the relevant one (a panel with action information). That element contains a script that controle the contents anyway. All I have to do is show that action on the tooltip and reset a counter. This counter is to make sure that the tooltip will only vanish when no panel has been detected for at least 0.5 seconds. No flashing then.


The gameplay thing is more interesting, I think. A worldobject in Holocene can be an incomplete building, a building, a unit or a resource. I wanted to have composite ones. For that, I made a goat, because you need goats. A goat is a unit, controlled by a non-human player, "Environment". It has some behaviour, running around from random place to random place. When it dies, it turns into a resource to be gathered. Gathering goat resources (food) will work exactly the same as gathering wood. Now, I'm writing this thing down and explaining it to my miniature greek helmet doubling as a rubber duck, I think I need some more thought here...


I think I'll make a new Animal class to inherit from Unit and that adds a slot for a prefab for a new Resource for once it dies. Animals always die to become a resource, at least that's the idea. I'll have to give some information to the player for the tooltip and selected object bar to show how much resources the animal will yield. That sounds better than my current disabling of components in the same object. Dead animals will look and behave different anyway, so why not make a better one.  Sorry if this does not make sense, but right now, I know what I mean!

No comments:

Post a Comment