An uncontrolled controller day

Hello again!

Since I’ve spent the whole day trying to figure out how to most efficiently (and by that I mean at all) make my player character move using the arrow keys, I thought I’d share some tutorial videos. No time for chit chat, gotta get some more stuff done before work 😀


This guy‘s got a whole series of free, very professional tutorials available on Youtube: course, which I’ve mentioned previously.

2D Character Controls (,). The scripting was outdated on this one, and I couldn’t figure out how to fix it. So I read a lot of error forums, like this one.

I spent time trying to use code from this forum, wondering why it looked so different from what I’ve been writing the past week or so. Then I realized some of the code had been written in JavaScript. Brilliant me.


I ended up using this code, brilliantly presented by this person:

  1. using UnityEngine;
  2. using System.Collections;
  3. public class Ctrl : MonoBehaviour
  4. {
  5. public float speed = 1.5f;
  6. void Update ()
  7. {
  8. if (Input.GetKey(KeyCode.LeftArrow))
  9. {
  10. transform.position += Vector3.left * speed * Time.deltaTime;
  11. }
  12. if (Input.GetKey(KeyCode.RightArrow))
  13. {
  14. transform.position += Vector3.right * speed * Time.deltaTime;
  15. }
  16. if (Input.GetKey(KeyCode.UpArrow))
  17. {
  18. transform.position += Vector3.up * speed * Time.deltaTime;
  19. }
  20. if (Input.GetKey(KeyCode.DownArrow))
  21. {
  22. transform.position += Vector3.down * speed * Time.deltaTime;
  23. }
  24. }
  25. }

I have also discovered the Unity Assets Store today! I didn’t actually download anything yet, but I snoozed around for a bit. Other than that, I spent some time reading in >here<.

Now, if you’ll excuse me, something is horribly wrong with my obstacle spawner and needs fixing… 😉