1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Entity Knockback

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

  1. Superomarking

    Superomarking Spider Jockey

    Messages:
    34
    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:
    137
    PHP:
    $entity = ....;///ENTITY
    $damager = .....;///DAMAGER 
    $entity->setMotion($entity->subtract($damage));
     
  3. Superomarking

    Superomarking Spider Jockey

    Messages:
    34
    GitHub:
    Superomarking
    so like

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

    minijaham Skeleton

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

    Superomarking Spider Jockey

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

    minijaham Skeleton

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

    Superomarking Spider Jockey

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

    Superomarking Spider Jockey

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

    minijaham Skeleton

    Messages:
    801
    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 Spider Jockey

    Messages:
    34
    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:
    189
    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 Spider Jockey

    Messages:
    34
    GitHub:
    Superomarking
    yes i found out how to fix this issue, thanks for the info tho
     
  13. Wanny

    Wanny Spider

    Messages:
    8
    how pls
     
  14. Superomarking

    Superomarking Spider Jockey

    Messages:
    34
    GitHub:
    Superomarking
    You might wanna make another post
     
  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.