The player needs to be able to interact with the game world, that’s what the interaction controller is used for! Picking up items, talking to an NPC … every Interact type event needs to be recognized by the player when it’s within range.
The interaction controller is a game object with a Rigidbody, a Collider (used as trigger) and the Interaction Controller component attached – first we need to create this object and turn it into a prefab. Then we’ll use this prefab in ORK Framework and have it automatically added to the player in the game. This way it doesn’t matter who the player is, he will always have the interaction controller ready to go, even if you change the player in the running game.
Admission controller gates the number of tasks that are permitted to run. 3D game for ARM tablets 27, and ported it to run on the Prime framework.
Let’s make this really easy by using the ORK Scene Wizard – open it Unity® menu: Window > ORK Scene Wizard.
Now use the scene wizard to create the interaction controller object: Create Object > Interaction Controller.
The scene wizard will create a new game object and add all necessary components (Collider, Rigidbody, Interaction Controller). A BoxCollider has been added by default – if you want a different collider, simply remove the BoxCollider component and add a different collider (don’t forget to enable the Is Trigger setting).
Now create a prefab out of this object by dragging it (it should be named Interaction Controller) from the scene hierarchy on the project tab. We’re done with the prefab, remove it from the scene.
Open the ORK Framework editor using the Unity® menu: Window > ORK Framework.
Navigate to Base/Control > Game Controls and edit the following settings.
Interaction Settings
The interaction settings handle everything related to interacting with the game world, i.e. wherever the Interact start type is used for interaction components (like Event Interaction, Item Collector, etc.).
- Interact Key
Select Accept.
This defines which input key is used to start interactions when they are within the interaction controller of the player. - Max Click Distance
Set to 3.
This defines how much distance between the player and the interaction is allowed to start the interaction by clicking/touching on it.
If you don’t want to interact by click/touch, set this to 0.
If click/touch should be allowed without a distance limitation, set this to -1.
Interaction Controller
- Add Automatically
Enable this setting.
The interaction controller will automatically be added to any player game object. - IC Prefab
Select the prefab we just created (Interaction Controller). - Offset
Set to X=0, Y=1 and Z=1.
This is the offset the prefab will have to the player.
Depending on your player’s game object, you need to vary the Offset setting. To find the best offset, simply pause the game when testing and place the Interaction Controller object where it suits your player best and use it’s position (found in the inspector of the transform) as offset.
When using multiple different players, it may come in handy to use a child object for placing the interaction controller. E.g. create an empty game object on every player combatant and place it where the interaction controller should be. Use this in the On Child setting (e.g. path/to/child).
Alternatively, you can also add the interaction controller object directly to the prefab of your player, but you need to disable Add Automatically.
Every object that should be recognized by the Interaction Controller also needs a Collider component! Otherwise the trigger of the interaction controller will never receive OnTriggerEnter or OnTriggerExit events.
Tip
When testing your game, you can see the number of available interactions in the inspector of the Interaction Controller.
Problems
If your interaction controller seems to be pushed away from your player, this could be happening because there also is a Rigidbody component on your player. To solve this, enabler Is Kinematic on the interaction controller.
Also, make sure the interaction controller’s collider is as Is Trigger enabled.
I am currently in the process of re-touching the user interface of a game (OpenLieroX namely). I am looking for a library/framework that would allow an easy GUI creation. To be concrete, these are my requirements:
- Open source - the game is LGPL and running into license issues is the last thing we want to care about :)
- Cross platform - at least Linux/Unix, Mac OS X and Windows 2k+ are a must but more is better.
- Stable and mature - I would prefer not using a project that will die in a month
- Fast and lightweight (less than 15 mb compiled) - it's for a game after all
- C++ interface - the game is written in C++
- Easy to use - tutorials and a good documentation are a big plus
- Easily adjustable - it should be easy to change the appearance of widgets
- An easy to use styling language - a simple language that designers can use to create appealing skins for the game
- An easy way to add custom widgets - I need to add viewports, character skins etc. to the interface and render them my way
- Support for off-screen rendering (into a buffer)
I have already tried these libraries:
- Webkit (various ports) - it's cool but not really made for game GUIs. Impossible to add custom elements with custom drawing (viewports etc.).
- Enlightenment - cool libraries but too Linux centric. Especially the Windows port is incomplete.
- Qt - great but offscreen rendering doesn't belong to its strenghts and mainly it's too big for the purpose
- GTK - quite the same problems as with Qt, poor Mac OS X support
I would highly appreciate if anyone knows a framework that could fit these needs. Thanks for your input.
Comments are closed.