- Home /
Unity 2D Jump script wont work on android but does on PC?
Heya guys so I know that this works for sure on the pc but when I install it onto android the jump does not work at all. Is there something wrong with this script any help is appreciated! I have been trying to fix this for 2 days now! using UnityEngine; using System.Collections; public class Runner : MonoBehaviour { public static float distanceTraveled; public Animation Jump = null; public float Speed = 2.0f; public Vector3 JumpHeight = new Vector3(); public bool IsOnGround; public float DeathHeight =-10; public GUISkin MyGUISkin; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if (Input.GetMouseButtonDown (0)) { if (IsOnGround) { rigidbody.AddForce (JumpHeight, ForceMode.VelocityChange); IsOnGround = false; } } if (!IsOnGround) { rigidbody.AddForce (transform.forward * Speed, ForceMode.VelocityChange); } if (gameObject.transform.position.y < DeathHeight) { rigidbody.velocity = new Vector3 (); gameObject.transform.position = new Vector3 (1, 14, 0); Destroy (GameObject.FindGameObjectWithTag ("PManager")); GameObject.FindGameObjectWithTag ("Manager").GetComponent<Manager> ().Reset (); } } void OnCollisionEnter (Collision other) { Debug.Log ("Collision"); { IsOnGround = true; } } void OnCollisionExit (Collision other) { Debug.Log ("Left Object"); { IsOnGround = false; } } }
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Is there any ifNot.Grounded command? 1 Answer
Changing the jump key in a premade code 4 Answers
Help With Simple Jump Script 1 Answer
Problems with jumping script 1 Answer