- Home /
How can i keep this button pressed without acctualy doing it ?
i got the code here : --->
using UnityEngine; using System.Collections;
public class controlPlayer : MonoBehaviour {
public float viteza ; // this is the speeed
void Update()
{
if(Input.GetKey(KeyCode.Q) ) //this if for the second camera when i press q the camera goes 90 degres to left and here are the controlls for that angle ...for the ball
//control camera 2
{ float miscaOrizontal = Input.GetAxis("Horizontal");
float miscaVertical = Input.GetAxis("Vertical");
Vector3 miscare = new Vector3(miscaVertical,0.0f,(-miscaOrizontal));
rigidbody.AddForce(miscare * viteza * Time.deltaTime);
}
if(Input.GetKey(KeyCode.E) ) //here when i try to go to camera 1 and also controls for ball for that angle
//control camera 1
{ float miscaOrizontal2 = Input.GetAxis("Horizontal");
float miscaVertical2 = Input.GetAxis("Vertical");
Vector3 miscare2 = new Vector3(miscaOrizontal2,0.0f,miscaVertical2);
rigidbody.AddForce(miscare2 * viteza * Time.deltaTime);
}
}
}
}
so the problem is that when i keep pressing E from my keyboard that ball goes using the arrows..but when i dont keep pressing E the ball doesnt roll...also for the other camera for the Q ...if i keep pressing the ball rolls ...if i dont the ball stops...
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613170009im_/https://answers.unity.com/themes/thub/images/avi.jpg)