Question by
SergiDis · Dec 03, 2015 at 01:55 PM ·
touch controlstouchscreen
Replace touch movement!
Hi, I'm starting slowly with Unity and I do not know much about programming. I need to change this, for tactile movement, which consists of a simple cube move from side to side, touching either side of the screen
public GameObject cube;
public float speed;
public float anglerotation;
void FixedUpdate()
{
//zero rotation
float turnAxisZ = 0;
// left and right keys affect cube
transform.Translate(Vector3.right *
Input.GetAxis("Horizontal")*
speed *
Time.deltaTime
);
// Calculating the left and right turn multiplying the rotation angle
giroEnEjeZ = Input.GetAxis("Horizontal")* -anguloDeGiro;
Cube.transform.rotation = Quaternion.Euler(0,0,giroEnEjeZ);
}
@khokhani1510
Comment
Your answer
Follow this Question
Related Questions
Touch Controls inaccurate after screen sleeping 0 Answers
Need help with touch controls for an android game. 1 Answer
Rotate Player w/Touch Input Controls 0 Answers
WebGL and videoplayer set frame not working in Unity 2019.4.0f1 1 Answer
how to make dialog box and how can i scroll the text using UI GUI buttons in Android / Touch 0 Answers