Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerMovement : MonoBehaviour
- {
- // Start is called before the first frame update
- [SerializeField] private Vector3 speedXY;
- private Vector3 moveXY;
- private float timeFrame;
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- Movement();
- }
- private void Movement()
- {
- timeFrame = Time.deltaTime;
- moveXY.x = Input.GetAxis("Horizontal");
- speedXY.x = 5f;
- moveXY.y = Input.GetAxis("Vertical");
- speedXY.y = 5f;
- transform.Translate(moveXY.x * speedXY.x * timeFrame, moveXY.y * speedXY.y * timeFrame, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement