Hey Guys
This might be a easy question, but i dont get how to change it…
With this script i can jump while pressing space…
How do i change this to a simple touch to jump?
Here is the script:
using UnityEngine;
using System.Collections;
public class runnerscript : MonoBehaviour {
public float Acceleration = 10;
public float maxSpeed = 10;
public Vector3 jumpVelocity;
private bool touchGround = false;
void Update () {
if (touchGround Input.GetButtonDown ("Jump")) {
rigidbody.AddRelativeForce (jumpVelocity, ForceMode.VelocityChange);
touchGround = false;
}
var curSpeed = rigidbody.velocity;
curSpeed.y = 0;
if (touchGround curSpeed.magnitude < maxSpeed) {
rigidbody.AddRelativeForce (Acceleration, 0, 0);
}
}
void OnCollisionEnter(){
touchGround = true;
}
}