We are proud to present our new touch control asset in version 2 for mobile games using Unity-3D’s new UI egnine uGUI.

So what is included? The Unity-package contains a prefab you can drag n drop to your Unity project. You can connect it to your player and start to test it directly in the Unity editor.

Here you can see a preview of the mobile controller in a Unity3d scene in this video:

You can buy the Unity-package from the Asset-Store here!

Follow these steps after importing our asset to your project:

Add the controller

Open the folder Prefabs and drag and drop the TouchControl prefab into your scene:

Touch control Unity prefab

Touch control Unity prefab

The prefab contains the controller knob on the left side (Stick_L) and the camera controller for rotating the camera on the right side (Stick_R).

When you have added the touch controller prefab to the scene, it should have the following setup to work with the scripts:

Adding the prefab to your scene

Adding the prefab to your scene

Setup for the Player

Player setup in Unity-3D for Touch Control

Player setup in Unity-3D for Touch Control

The player is an empty GameObject to which you add your character mesh (e.g. fbx import of your model) as child. Then you define the tag Player for the Player object and add the following components to it:

  • CharacterController (or Rigidbody)
  • The PlayerController script
  • A Capsule Collider (or any other collider)

Of course you can also use our Player setup from the included demo.

Adding animations

In the sample scene (TouchControlDemo) we added a rabbit character and defined a humandoid rig for him. This means that we are able to use animations for a humanoid character which are included in many Unity demos or in free Unity packs available in the assetstore.

We added a simple Mecanim animation controller to switch between the animations Idle and Run. The parameter we used to switch the animation is called MoveSpeed. This parameter is referred to in the scripts included.

You can use this RabbitController also for your game and change it that it fits your needs.

What to implement

After this setup you should be able to control your character in the Unity editor and also on your mobile device. The main logic for moving, rotating and animating a character resides in the scripts PlayerController. This script is a default implementation of the interface IPlayerController from our package. You can just use it or change it for your game.

For the Camera movement we added a StickCameraController script which is attached to the right Stick. you can just take this as is and change the parameters of the script like:

  • Angle X
  • MinAngle X
  • MaxAngle X
  • Distance
  • Rotation speed X
  • Rotation speed Y
  • Allow X
  • Allow Y

All script are included and added to the prefab TouchController, you can use them as they are or change them as you like.

When I am stuck?

If you have any questions, problems or something does not work and you can’t get it working, please write a message to the jayanam or write a comment here on facebook or G+. You can also drop us as line via email but the preferred way is to write to social media or in Unity assetstore so that others developers also get the solution.

(Visited 2,900 times, 1 visits today)