Apart from movement which works i cannot script a dash function. i tried it with a context callback which doesnt work but i also tried it with a key press ( wasPressedThisFrame ) i want my player to dash in the direction he is looking at. Now with the old system this code worked fine from idle and running state.
I’ll skip the whole function since by using this line here : rb2d.velocity = transform.right * dashSpeed; does absolutely nothing on either button call or context call.
I was told that maybe the movement vector messed it up so i temporarily deleted all movement vectors but still it wont work. Here is the movement code just in case you need it!
public void PlayerDirectionInput(InputAction.CallbackContext context)
{
movementVector = context.ReadValue<Vector2>();
if (!freezeInput)
{
movementX = movementVector.x;
movementY = movementVector.y;
Debug.Log(movementVector);
}
}
and yeah why not here is the messed up dashing script in case anyone can help!
keep in mind Player Input Invoke Unity Event behavior only update when the Input values has changed
context.performed does not function like mono behavior Update() or FixedUpdate(), this is most common mistake when switching to the new Input System, I can tell by saw the Time.deltaTime inside context.performed
context.performed does not function like mono behavior Update() or FixedUpdate().
thank you guys but for some reason i figured it out. i set the actual velocity and movement on another function that i call from update and in the input action context function i did it like this.
public void OnDash(InputAction.CallbackContext context)
{
if (context.performed)
{
if (context.interaction is TapInteraction)
{
Instantiate(dashEffect, transform.position, Quaternion.identity);
Debug.Log("Performed dash");
canDash = false;
}
}
if (context.started)
{
canDash = true;
}
if (context.canceled)
{
canDash = false;
}
}