Advertisement
crystalguy123

Untitled

Feb 1st, 2020
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayerMovement : MonoBehaviour
  6. {
  7. // Start is called before the first frame update
  8.  
  9. [SerializeField] private Vector3 speedXY;
  10. private Vector3 moveXY;
  11. private float timeFrame;
  12.  
  13. void Start()
  14. {
  15.  
  16. }
  17.  
  18. // Update is called once per frame
  19. void Update()
  20. {
  21. Movement();
  22. }
  23.  
  24. private void Movement()
  25. {
  26. timeFrame = Time.deltaTime;
  27. moveXY.x = Input.GetAxis("Horizontal");
  28. speedXY.x = 5f;
  29. moveXY.y = Input.GetAxis("Vertical");
  30. speedXY.y = 5f;
  31. transform.Translate(moveXY.x * speedXY.x * timeFrame, moveXY.y * speedXY.y * timeFrame, 0);
  32. }
  33.  
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement