Voila voila , je reviens vers vous pour un petit soucis ma foi assez gênant....
Explication :
Je suit un tutoriel , ( que vous pouvez trouvez ici : https://www.youtube.com/watch?v=aPy_eI2pQcc&t=19s) qui explique comment faire avancer le personnage , ainsi que lui faire bouger la caméra , mais petit problème dans le script et sur la console , Unity ne trouve pas le Rigidbody pourtant bien assigner à mon "Player"
Screen & Scripts :
Code : Tout sélectionner
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class PlayerMotor : MonoBehaviour {
[SerializeField]
private Camera cam;
private Vector3 velocity;
private Vector3 rotation;
private Vector3 cameraRotation;
private Rigidbody rb;
private void start()
{
rb = GetComponent<Rigidbody>();
}
public void Move(Vector3 _velocity)
{
velocity = _velocity;
}
public void Rotate(Vector3 _rotation)
{
rotation = _rotation;
}
public void RotateCamera(Vector3 _cameraRotation)
{
cameraRotation = _cameraRotation;
}
private void FixedUpdate()
{
PerformMovement();
PerformRotation();
}
private void PerformMovement() {
if (velocity != Vector3.zero)
{
rb.MovePosition(rb.position + velocity * Time.fixedDeltaTime);
}
}
private void PerformRotation()
{
rb.MoveRotation(rb.rotation * Quaternion.Euler(rotation));
cam.transform.Rotate(-cameraRotation);
}
}
Code : Tout sélectionner
PerformRotation();
Code : Tout sélectionner
rb.MoveRotation(rb.rotation * Quaternion.Euler(rotation));
Merci de votre aide.