PlayerMove
Blockmove both reset
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerMove : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float speed;
|
||||
[SerializeField] private Rigidbody rb;
|
||||
[SerializeField] private Vector3 StartPos;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
float horizontalInput = Input.GetAxis("Horizontal");
|
||||
float verticalInput = Input.GetAxis("Vertical");
|
||||
|
||||
Vector3 moveDirection = new Vector3(horizontalInput,0, verticalInput);
|
||||
moveDirection.Normalize();
|
||||
|
||||
|
||||
transform.Translate(moveDirection * speed * Time.deltaTime, Space.World);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this.transform.position = StartPos;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b9bab48a629093449f53dc5ea63d752
|
||||
Reference in New Issue
Block a user