- Home /
How to use virtual Joystick.js (Mobile Assets) with the default ThirdPersonController?
My character has the default script ThirdPersonController.js. I want to create a joystick on my screen which would enable it to move on touch screen. Whenever I import a joystick, it doesn't allow me to control my character with it. How can I get the Input/Output of the joysticks? How can I maodify my ThirdPersonControlller sript to make the player move.? Please provide the whole code for both the Joystick.js and ThirdPersonCOntroller.js. Thanks in advance.
Answer by HolBol · Jul 13, 2014 at 01:36 AM
Took me a while to figure out too. Open your TPC script and add this:
var moveJoystick : Joystick;
var XInput : float;
var YInput : float;
And in Awake () add this:
XInput = moveJoystick.position.x;
YInput = moveJoystick.position.y;
h = XInput;
v = YInput;
Then in the editor simply drag and drop your SIngle Joystick object onto the inspector variable for the ThirdPersonController. Worked for me, anyway.
Assets/Standard Assets/Character Controllers/Sources/Scripts/ThirdPersonController.js(5,20): BCE0018: The name 'Joystick' does not denote a valid type ('not found').
This is the error I get when do as you said.
got that figured out. No error now. But the joystick doesn't work :(
Answer by Victor-K · Oct 16, 2014 at 08:47 AM
Extremely easy and intuitive to use, Touch Controls Kit allows you to quickly and easily develop actions based on a touchscreen, buttonб joystick, touchpad dpad and tilt.
Your answer
Follow this Question
Related Questions
gui rotational issues 0 Answers
Unity 4.5 - Can't find UI in the “Create” list 2 Answers
Access clicked button from the different function 1 Answer
Converting world coordinates to screen coordinates 1 Answer
Unity3d build project gui 0 Answers