fr0stn1k

Unity(Task2_day2)_Kovylov

Mar 9th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class CameraController : MonoBehaviour
  4. {
  5.     private float _path;
  6.     [Range(5,10)]
  7.     public float speed = 5;
  8.    
  9.     // Update is called once per frame
  10.     void Update ()
  11.     {
  12.         _path = speed * Time.deltaTime;
  13.  
  14.         if (Input.GetKey(KeyCode.A))
  15.         {
  16.             transform.Translate(Vector3.left.normalized * _path);
  17.         }
  18.  
  19.         if (Input.GetKey(KeyCode.D))
  20.         {
  21.             transform.Translate(Vector3.right.normalized * _path);
  22.         }
  23.  
  24.         if (Input.GetKey(KeyCode.W))
  25.         {
  26.             transform.Translate(Vector3.up.normalized * _path);
  27.         }
  28.  
  29.         if (Input.GetKey(KeyCode.S))
  30.         {
  31.             transform.Translate(Vector3.down.normalized * _path);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment