Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Player : MonoBehaviour
- {
- [SerializeField] private float speed;
- [SerializeField] private float horizontalInput;
- [SerializeField] private float verticalInput;
- // Start is called before the first frame update
- void Update()
- {
- horizontalInput = Input.GetAxis("Horizontal");
- verticalInput = Input.GetAxis("Vertical");
- // new vector3(-1,0,0) * 5 * real time
- transform.Translate(new Vector3(horizontalInput,0,verticalInput) * speed * Time.deltaTime);
- if (Input.GetKeyDown(KeyCode.Space))
- {
- //Game Paused
- Time.timeScale = 0;
- print("Uou Pressed Space To Paused ");
- }
- if (Input.GetKeyDown(KeyCode.Escape))
- {
- print("You Pressed ESC. To resume");
- Time.timeScale = 1;
- }
- if (Input.GetKeyDown(KeyCode.Backspace))
- {
- print("You Pressed ESC. To resume");
- Time.timeScale = 0.5f;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement