#dash - applyKnockback

1 messages · Page 1 of 1 (latest)

tacit crystal
#

Im trying to make this work but math isnt one of my strengths

system.runInterval(() => {
  for (const player of players) {
    
    if (!player.isSneaking) {
      return void sneakToggle.delete(player);
    }

    const movementVector = player.inputInfo.getMovementVector();
    
    if ((movementVector.x !== 0 || movementVector.y !== 0)) {
      if (sneakToggle.has(player)) return;
      sneakToggle.set(player, true);

      const now = Date.now();
      if (dashCooldowns.has(player) && dashCooldowns.get(player) > now)
        return;

      dashCooldowns.set(player, now + DASH_COOLDOWN);
      dash(player, movementVector, 0.7);
      console.log("DASH");
    }
  }
});

// THIS IS THE PART I NEED TO MAKE WORK
function dash(player: Player, vector: Vector2, strength: number) {
  // vector is movementVector
  // The player should be boosted in the direction he is currently walking
}
frank maple
#

applyKnockback({ x: x * hStrength, z: z * hStrength }, vStrength)
instead of applyKnockback(x, z, hStrength, vStrength)

compact edge
#

you kinda didnt post with applyKnockback function...

frank maple
#

Also that ^

tacit crystal
compact edge
#

i...

#

dont know how to help then???

#

you mentioned that you kept getting launched into air

tacit crystal
#

? I just want that dash does that it says

tacit crystal
#

.. somehow it isnt boosting me in the air now but it boosted me staticly in one direction, ill send it

#
  player.applyKnockback({ x: vector.x * hStrength, z: vector.y * hStrength }, vStrength);
#

I think my issue is, that i dont even know what each property is

#

maybe i forgot to calculate the players body rotation.. idk

compact edge
tacit crystal
#

Yes, but I need to include the player view

compact edge
#

what do you mean? like, you need to account for player's view direction too?

tacit crystal
#

Sorry for the late response, i have somehow fixxed it