using UnityEngine;
using System.Collections;
public class Ninja : MonoBehaviour {
float speed = 7.0f;
// Use this for initialization
void Start () {
transform.position = new Vector3 (2, 8, -5);
}
// Update is called once per frame
void update () {
if (coll.collider == false & Input.GetKey (KeyCode.UpArrow)) {
Debug.Log ("up");
}
}
void faceRight () {
transform.localRotation = Quaternion.Euler (0, 0, 0);
}
void OnCollisionStay2D(Collision2D coll){
// If the Collider2D component is enabled on the object we collided with.
if (coll.collider == true) {
if (Input.GetKey (KeyCode.LeftArrow)) {
Debug.Log ("left arrow");
transform.position += Vector3.left * speed * Time.deltaTime;
}
if (Input.GetKey (KeyCode.RightArrow)) {
Debug.Log ("right arrow");
transform.position += Vector3.right * speed * Time.deltaTime;
}
}
}
}
↧