- Home /
Question by
Developerx · Jan 30, 2014 at 08:16 PM ·
androidjavascriptmonodeveloptouchscreen
I need help making this script work for android touchscreen
I am trying to develop a JavaScript that will allow me to rotate the character in z axis by swiping left and right on my android device. Here is what I have But it only works on pc.
// Smoothly tilts a transform towards a target rotation.
var smooth = 2.0;
var tiltAngle = 30.0;
function Update () {
var tiltAroundZ = Input.GetAxis("Horizontal") * tiltAngle;
var tiltAroundX = Input.GetAxis("Vertical") * tiltAngle;
var target = Quaternion.Euler (tiltAroundX, 0, tiltAroundZ);
// Dampen towards the target rotation
transform.rotation = Quaternion.Slerp(transform.rotation, target,Time.deltaTime * smooth);; }
Thanks
Comment
Your answer
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Object deformation on activat 0 Answers