I am a newbie, and i have been trying the flappy bird style tutorial, and it is working fine.
https://unity3d.com/learn/live-training/session/making-flappy-bird-style-game
Now i would like to test it in webgl in a browser on computer and mobile devices.
In the tutorial it uses the lfm button.
How can i add a “touch” script to my control of the bird, i have added the spacebar button, i’d like to have 3 ways of “flapping”
thx
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bird : MonoBehaviour {
public float upForce = 200f;
private bool isDead = false;
private Rigidbody2D rb2d;
private Animator anim;
// Use this for initialization
void Start () {
rb2d = GetComponent ();
anim = GetComponent ();
}
// Update is called once per frame
void Update () {
if (isDead == false) {
if (Input.GetMouseButton (0)) {
rb2d.velocity = Vector2.zero;
rb2d.AddForce (new Vector2 (0, upForce));
anim.SetTrigger (“Flap”);
} else if (Input.GetKeyDown (“space”)) {
rb2d.velocity = Vector2.zero;
rb2d.AddForce (new Vector2 (0, upForce));
anim.SetTrigger (“Flap”);
}
}
}
void OnCollisionEnter2D (){
rb2d.velocity = Vector2.zero;
isDead = true;
anim.SetTrigger (“Die”);
GameControl.instance.BirdDied ();
}
}