Advertisement
Wolverine_X-Man

Untitled

Mar 6th, 2021
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 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.     void Start()
  12.     {
  13.        
  14.     }
  15.  
  16.     void Update()
  17.     {
  18.         horizontalInput = Input.GetAxis("Horizontal");
  19.         verticalInput = Input.GetAxis("Vertical");
  20.         //  new vector3(-1,0,0) * 5 * real time
  21.         transform.Translate(new Vector3(horizontalInput,verticalInput,0) * speed * Time.deltaTime);
  22.     }
  23. }
  24.  
  25. /* Games With Wolverine */
  26. /* Thankyou Baccho */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement