Advertisement
kalin729

2D Move Up and Down

Jan 21st, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Move : MonoBehaviour {
  6.  
  7.     public float moveSpeed;
  8.  
  9.     // Use this for initialization
  10.     void Start () {
  11.        
  12.     }
  13.    
  14.     // Update is called once per frame
  15.     void Update () {
  16.  
  17.  
  18.         if (Input.GetKey (KeyCode.UpArrow)) {
  19.             transform.Translate (new Vector3 (0, moveSpeed, 0) * Time.deltaTime);
  20.         }
  21.  
  22.         if (Input.GetKey (KeyCode.DownArrow)) {
  23.             transform.Translate (new Vector3 (0,  -moveSpeed, 0) * Time.deltaTime);
  24.         }
  25.        
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement