Quantcast
Channel: Questions in topic: "parser"
Viewing all articles
Browse latest Browse all 108

How can I get this code to recognize coll in my update function?

$
0
0
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; } } } }

Viewing all articles
Browse latest Browse all 108

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>