- Home /
This question was
closed Apr 07, 2014 at 11:24 PM by
Benproductions1 for the following reason:
Not specific or technical
Script for jump when screen is touched (C#)
Hi Guys,
I am trying out a script for my player to jump when the screen is jumped, i am using the latest unity software and im making a 2d unity platform game.
Script
using UnityEngine;
using System.Collections;
public class AndroidJump : MonoBehaviour {
public bool grounded = true;
public float jumpPower = 1;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(!grounded && rigidbody2D.velocity.y == 0) {
grounded = true;
}
if (Input.touchCount == 1 && grounded == true) {
rigidbody2D.AddForce(transform.up*jumpPower);
grounded = false;
}
}
}
Comment
The question is can you help me fix the script as it doesnt seem to be working.
Thanks
That's not a technical, specific or proper question. We aren't here to do your work for you, were here to help you do your work.
Answer by andrew_196 · Apr 07, 2014 at 11:24 PM
if you want to regester a screen touch on a device which I presume is what you are asking you could use
if (Input.GetMouseButtonDown(0))
{
Jump();
}