Hi All,
I can only assume this is related to my lack of understanding with the new input system, and some sort of “infinite loop” is happening in the background. I’m using Unity 2020.3.212f1. My project is nearly empty, but I do have all of the assets that I plan to use loaded in with the package manager, just not much is in my scene yet. I have tested these assets before in a different project (I think it was Unity 2019 version) with the old input system, and I didn’t have any issues.
I’m using the new input system with Unity Events, and I’ve been calling them like this:
I’m using an Input Manager script: Loading...
I’m then getting the reference by doing things like this in various scripts:
public void Cast(InputAction.CallbackContext context)
{
if (context.performed)
{
gamepadTriggerHeld = context.control.IsPressed();
spaceKeyHeld = context.control.IsPressed();
}
}
public void Jump(InputAction.CallbackContext context)
{
if (context.performed && RaycastGroundCheck())
rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);
}
This seems to work, but is this correct? I am not doing OnEnable() or OnDisable() anywhere, and I’m wondering if I’m getting some issues because of this.
I think I’ve done my movement wrong as well, that could be a contributing factor.
This function below is then called in FixedUpdate():
private void PlayerMovement()
{
forceDirection += moveInput.x * movementForce * GetCameraRight(playerCamera);
forceDirection += moveInput.y * movementForce * GetCameraForward(playerCamera);
rb.AddForce(forceDirection, ForceMode.Impulse);
forceDirection = Vector3.zero;
Vector3 horzontalVelocity = rb.velocity;
horzontalVelocity.y = 0;
}
I know input shouldn’t be set in FixedUpdate() to begin with, but this shouldn’t be the cause of the freezing/crashes.