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
- {
- public float moveSpeed = 10f;
- private float movementX;
- private float movementY;
- void HandlePlayerMovement()
- {
- movementX = Input.GetAxisRaw("Horizontal");
- movementY = Input.GetAxisRaw("Vertical");
- transform.position += new Vector3(movementX, 0f, 0f) * moveSpeed * Time.deltaTime;
- transform.position += new Vector3(0f, movementY, 0f) * moveSpeed * Time.deltaTime;
- }
- // Update is called once per frame
- void Update()
- {
- HandlePlayerMovement();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement