Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class BasicConditionals : MonoBehaviour {
  5.  
  6. //make new public bool and GameObjects
  7. //remember that public means they can be edited in the Unity editor and by other scripts
  8. public bool goToWork;
  9. public GameObject mover;
  10.  
  11. // Use this for initialization, similar to void setup() in Processing
  12. void Start () {
  13.  
  14. }
  15.  
  16. // Update is called once per frame, similar to void draw() in Processing
  17. void Update () {
  18. Debug.Log("game object is at ... " + mover.transform.position);
  19.  
  20. //check if the GetKeyDown function of Input returns true for "space" (the space bar)
  21. if (Input.GetKeyDown("w")){
  22. //if true ... move the position of mover by (0,1,0)
  23. mover.transform.position += new Vector3(0,0,1);
  24. }
  25.  
  26. if (Input.GetKeyDown("d")){
  27. mover.transform.position += new Vector3(1,0,0);
  28. }
  29.  
  30. if (Input.GetKeyDown("a")){
  31. mover.transform.position += new Vector3(-1,0,0);
  32.  
  33. }
  34.  
  35. if (mover.transform.position == new Vector3(11,0,0)){
  36.  
  37. mover.transform.position += new Vector3(0,0,0);
  38. }
  39.  
  40. if (mover.transform.position == new Vector3(0,11,0)){
  41.  
  42. mover.transform.position += new Vector3(0,0,0);
  43. }
  44.  
  45. if (mover.transform.position == new Vector3(0,0,11)){
  46.  
  47. mover.transform.position += new Vector3(0,0,0);
  48. }
  49. //Tried to reset the player's original position after hitting off of the box
  50.  
  51. //check it the mover's position is equal to (0,5,0)
  52. //if (mover.transform.position == new Vector3(0,5,0)){
  53. //if it is, add on this additional position (5,-5,0)
  54. // mover.transform.position += new Vector3(0,1,0);
  55. //}
  56. }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement