Changelog 4 In Which A Tradition Is Upheld
Another changelog is out. I’ve tested and polished the interactivity system, allowing entities to be “used” by the player.
- Interactivity System
- Plugin Documentation
Under The Hood - Using Objects
The interactivity system is really very simple, actually it’s so simple I almost decided not to write this section! The player character has an ItemUser behaviour attached to it which listens for UseKeyPressed events from the input system. When the behaviour receives an event it projects a short ray into the world (out from the camera position) and finds out what entities it hits. For each entity it does two things:
- If the entity has a behaviour which implements the IItemUsable interface then the Use(EntityId user) method is called on that behaviour.
- A general event is broadcast indicating that entity A used entity B.
And that’s really it. To make an object interactive you simply need to attach a behaviour implementing IItemUsable to the behaviour and you’re sorted. Or if you want to listen to other entities being interacted with for some reason you can just listen for the event.
blog comments powered by Disqus