You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
815 B
32 lines
815 B
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;
|
|
}
|
|
}
|