I’m having trouble with this code. I compiled it and no errors (A first) but nothing happens when i press the keys. I have set an input set for Horizontal2 and Vertical2.
my code:
public class JetpackScript : MonoBehaviour {
Rigidbody rb;
ParticleSystem ps;
void Start () {
rb = GetComponent<Rigidbody> ();
ps = GetComponent<ParticleSystem> ();
}
void FixedUpdate () {
float horizontal = Input.GetAxis ("Horizontal2");
float vertical = Input.GetAxis ("Vertical2");
if (vertical > 0) {
Debug.Log (vertical);
}
if (vertical > 0.001f) {
ps.Play ();
rb.AddForce (0.0f, 1.0f, 0.0f);
}
else
{
ps.Stop ();
}
rb.AddForce (horizontal, 0.0f, 0.0f);
}
}