Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

need help with simple c# movement script

$
0
0
Hi, I don't understand what's wrong with this script, this has happened with several scripts I've tried. Basically it's all in red, most of the errors are from functions apparently not being in the current context etc. Keywords aren't working and are coming up with question marks in the debug panel. Here's the code: using UnityEngine; using System.Collections; public class playerControl : MonoBehaviour { public float speed = 5f; // Use this for initialization void Start () { } // Update is called once per frame void Update () { Movement (); } void Movement() { if (Input.GetKey (KeyCode.D)) { transform.Translate (Vector2.right * speed * Time.deltaTime); } else if (Input.GetKey (KeyCode.A)) { transform.Translate (Vector2.left * speed * Time.deltaTime); } } } Any help would be majorly appreciated. If it is a simple mistake/typo etc, could you please also explain what I've screwed up and why it has screwed it up? I would love to understand because this is Uber annoying : / Thanks in advance :)

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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