using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Barco : MonoBehaviour {
public Text textoScore;
public int puntos=0;
public float speed = 10.0F;
void Update() {
textoScore.text = ""+puntos;
//accelerometro
Vector3 dir = Vector3.zero;
dir.x = Input.acceleration.x;
if (dir.sqrMagnitude > 1)
dir.Normalize();
//Añadimos velocidad
rigidbody2D.velocity = new Vector2 (dir.x * speed, 0);
}
//Miramos si ha entrado algun objeto
void OnTriggerEnter2D(Collider2D other){
//si el objeto es un enemigo lo destruimos y ganamos 1 punto
if (other.gameObject.tag == "enemy") {
puntos=puntos+1;
Destroy (other.gameObject);
}
1 Response
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.