using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float movementSpeed = 1;
Rigidbody rb;
void Start()
{
rb = GetComponent();
}
void Update()
{
Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical")) * movementSpeed;
move = Vector3.ClampMagnitude(move, movementSpeed);
if (move != Vector3.zero)
{
rb.MovePosition(transform.position + move * Time.deltaTime);
rb.MovePosition(Quaternion.LookRotation(move));
}
}
}
-
Вопрос задан
-
266 просмотров