2d
This commit is contained in:
24
2D/Assets/Scripts/PlayerMovement.cs
Normal file
24
2D/Assets/Scripts/PlayerMovement.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
public float movespeed = 15f;
|
||||
|
||||
public Rigidbody2D rb;
|
||||
Vector2 movement;
|
||||
// Update is called once per frame
|
||||
|
||||
void Update()
|
||||
{
|
||||
//Input
|
||||
movement.x = Input.GetAxisRaw("Horizontal");
|
||||
movement.y = Input.GetAxisRaw("Vertical");
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
//Movement
|
||||
rb.MovePosition(rb.position + movement * movespeed * Time.fixedDeltaTime);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user