Advertisement
Wolverine_X-Man

Player.cs

Mar 6th, 2021
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class Player : MonoBehaviour
  4. {
  5.  
  6.     [SerializeField] private float speed;
  7.  
  8.     [SerializeField] private float horizontalInput;
  9.     [SerializeField] private float verticalInput;
  10.     // Start is called before the first frame update
  11.  
  12.     void Update()
  13.     {
  14.         horizontalInput = Input.GetAxis("Horizontal");
  15.         verticalInput = Input.GetAxis("Vertical");
  16.         //  new vector3(-1,0,0) * 5 * real time
  17.         transform.Translate(new Vector3(horizontalInput,0,verticalInput) * speed * Time.deltaTime);
  18.  
  19.         if (Input.GetKeyDown(KeyCode.Space))
  20.         {
  21.             //Game Paused
  22.             Time.timeScale = 0;
  23.             print("Uou Pressed Space To Paused ");
  24.         }
  25.  
  26.         if (Input.GetKeyDown(KeyCode.Escape))
  27.         {
  28.             print("You Pressed ESC. To resume");
  29.             Time.timeScale = 1;
  30.         }
  31.        
  32.         if (Input.GetKeyDown(KeyCode.Backspace))
  33.         {
  34.             print("You Pressed ESC. To resume");
  35.             Time.timeScale = 0.5f;
  36.         }
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement