More about Actionable Objects. ( InterAction Project Series )

Let’s have a look how this little system I am doing enables the player to open and close this power block door, as a simple example.

The orange door you see in the scene view in the picture above has a component called ActionableObject. If the layer „ActionableObjects“ exists, a GameObject with this component on it will be set to this layer. This is needed because the raytracing of the EyeModule only hits on objects in this layer. (If the layer does not exist, errors will be thrown, but there is a convient editor menu where you can create all needed layers without having to add them manually.)

First, when everything is setup, this is an example what then is shown as UI if the player looks at an Actionable Object. But this is, and this is the reason this whole thing, not hardcoded. You can customize every action in the inspector easily.

Example for the Action UI being created out of the information of an actionable object.

Before defining a list of possible actions, you can define an optional image for the AO shown in the ActionMenu Prefab. Of course, since the ActionMenu Prefab can be customized, this is only a very simple example how it could look

But how does a door for example knows if its open or closed ? That is where the Flag System Manager Component comes into play. Every ActionableObject can register flags there. The Flag System Manger is by default a component of the Game Scene Controller.

Now to the meat : Every Player Action is an entry in a list in the ActionableObject. The Player Action enumeration drop box is necessary (but this will change), since this defines the connection between the Input Manager Callback, thus the button or key pressed. (I set the OnUse entry in the Input Manager Asset to ‚E‘)

The menu name is what will be displayed in the entry in the action menu. Also there is an optional text that can be displayed when the AO gets the focus (the player is looking at it), but this is not implemented right now. The key is which keyboard key activates the action (only a visible, the real input trigger is defined in the Input Manager Asset). One can also show an icon like a mouse key icon, but this is not implemented here only in another branch for now.

If the player chooses one of those actions, hier the Use Action as example, the following can happen : There are so called Action Data Blocks. Those are Scriptable Assets.

Right now this is basicly a place holder for playing an animation and an audio clip.

Also, UnityEvents can be used to cal l methods in hierarchy objects.

There is also the option to delete the action after it has been used once, so that it is no longer available.

Now to the flags : Every action can be made useable (visible) or unusable (invisible) by the use of flags. You can specify which flags have to be set as true and which has to be set as false. These flags can be from other AOs or any logic that uses the Flag System Manager.

Also you can specify which flags should be switched in its boolean value (from false to true or vice versa) after the action has been choosen by the player. With this you can easily realize things like doors or light switches.

So far for now. I will update this here accordingly to my progress with the system. This is also a stub for the documentation for when I puplish this system as Open Source. But I think that is obvious. 😀

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.