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 = 5f;
- public Rigidbody2D rb;
- Vector2 movement;
- void Update()
- {//check for inputs
- movement.x = Input.GetAxisRaw("Horizontal");
- movement.y = Input.GetAxisRaw("Vertical");
- }
- void FixedUpdate()
- {//for movement
- rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement