Pouvez-vous m'aider ?
Voici la première partie du message d'erreur:
UnityEngine.UIElements.EventCallbackFunctor`1[TEventType].Invoke (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.PropagationPhase propagationPhase) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Events/EventCallback.cs:79)
UnityEngine.UIElements.EventCallbackRegistry.InvokeCallbacks (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.PropagationPhase propagationPhase) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Events/EventCallbackRegistry.cs:353)
UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Events/EventHandler.cs:259)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Events/EventHandler.cs:189)
UnityEngine.UIElements.CallbackEventHandler.UnityEngine.UIElements.IEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Events/EventHandler.cs:206)
UnityEngine.UIElements.EventDispatchUtilities.HandleEventAcrossPropagationPath (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Events/IEventDispatchingStrategy.cs:143)
UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Events/IEventDispatchingStrategy.cs:90)
UnityEngine.UIElements.DefaultDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Events/DefaultDispatchingStrategy.cs:15)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:422)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at /Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/EventDispatcher.cs:363
Et voici les deux scripts:
Code : Tout sélectionner
using System;
using UnityEngine;
[RequireComponent(typeof(PlayerMotor))]
public class PlayerController : MonoBehaviour
{
[SerializeField]
private float speed;
private PlayerMotor motor;
private void Awake()
{
motor = GetComponent<PlayerMotor>();
}
private void Start()
{
motor.Init();
{
private void Udapte()
{
// Calculer la vélocité (vitesse) du mouvement de notre joueur
float xMov = Input.GetAxisRaw("Horizontal");
float zMov = Input.GetAxisRaw("Vertical");
Vector3 moveHorizontal = transform.right * xMov;
Vector3 moveVertical = transform.forward * zMov;
Vector3 velocity = (moveHorizontal + moveVertical).normalized * speed;
//On calcule la rotation du joueur en un vector3
float yRot = Input.GetAxis("Mouse X");
} }
private class PlayerMotor
{
internal void Init()
{
throw new NotImplementedException();
}
internal void Move(Vector3 velocity)
{
throw new NotImplementedException();
}
}
}
Code : Tout sélectionner
using System;
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class PlayerMotor : MonoBehaviour
{
private Vector3 velocity;
private Rigidbody rb;
private void Init()
{
rb = GetComponent<Rigidbody>();
}
public void Move(Vector3 _velocity)
{
velocity = _velocity;
}
private void FixedUdapte()
{
PerformMovement();
}
private void PerformMovement()
{
if(velocity != Vector3.zero)
{
rb.MovePosition(rb.position + velocity * Time.fixedDeltaTime);
}
}
}
/code]