Entity Knockback

Discussion in 'Development' started by Superomarking, Jun 7, 2021.

  1. Superomarking

    Superomarking Silverfish

    Messages:
    21
    GitHub:
    Superomarking
    hey, question, how can i add knockback to an entity, i tried using $entity->setMotion(0.5, 0.5, 0.5); and parent::knockBack($attacker, $damage, 0.5, 0.5, 0.5); but there both wacky
     
  2. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    115
    PHP:
    $entity = ....;///ENTITY
    $damager = .....;///DAMAGER 
    $entity->setMotion($entity->subtract($damage));
     
  3. Superomarking

    Superomarking Silverfish

    Messages:
    21
    GitHub:
    Superomarking
    so like

    $damager = $event->getPlayer();
    $entity->setMotion($entity->subtract($damager));
     
  4. minijaham

    minijaham Zombie Pigman

    Messages:
    530
    GitHub:
    minijaham
    Can't you just do
    PHP:
    $entity->knockBack(Entity $attackerfloat $damagefloat $xfloat $zfloat $base);
     
    Primus, ErikX and ethaniccc like this.
  5. Superomarking

    Superomarking Silverfish

    Messages:
    21
    GitHub:
    Superomarking
    I tried it, and no it doesn’t work
     
  6. minijaham

    minijaham Zombie Pigman

    Messages:
    530
    GitHub:
    minijaham
    What exactly do you mean it doesn't work?
     
    Primus and ErikX like this.
  7. Superomarking

    Superomarking Silverfish

    Messages:
    21
    GitHub:
    Superomarking
    $base should be $base = 0.4 or higher
     
  8. Superomarking

    Superomarking Silverfish

    Messages:
    21
    GitHub:
    Superomarking
    also it just doesn’t take kb at all it just jumps
     
  9. minijaham

    minijaham Zombie Pigman

    Messages:
    530
    GitHub:
    minijaham
    Perhaps you’re using it wrong? This function is used to give knockback to players on hit too
     
    Primus likes this.
  10. Superomarking

    Superomarking Silverfish

    Messages:
    21
    GitHub:
    Superomarking
    i just want the entity to take knockback, i already made the player knockback on another plugin
     
  11. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    184
    GitHub:
    ethaniccc
    if you're overriding the motion every tick to make the entity walk in a certain direction, it's never going to take knockback because it's just going to use the walking motion
     
  12. Superomarking

    Superomarking Silverfish

    Messages:
    21
    GitHub:
    Superomarking
    yes i found out how to fix this issue, thanks for the info tho
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.