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

How can I make an arrow go faster?

Discussion in 'Development' started by DiamondGamer30, Jul 15, 2018.

  1. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    I'm trying to make a custom enchant that increases the speed of a projectile but I don't know what I would have to do to do that.
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Multiply it's motion?
    Code:
    arrow->setMotion(arrow->getMotion()->multiply(4))
    
     
    xXNiceAssassinlo YT likes this.
  3. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    I'll try that, thanks.
     
  4. Primus

    Primus Zombie Pigman

    Messages:
    749
    Look what I found: docs.pocketmine.net/EntityShootBowEvent.php and this is how currently force is calculated
    PHP:
    # pocketmine/item/Bow.php (Line: 62 - 64)
    /* 62 */ 
    $diff $player->getItemUseDuration();
    /* 63 */ $p $diff 20;
    /* 64 */ $force min((($p ** 2) + $p 2) / 31) * 2;
    I'm sure that $event->setForce($event->getForce() * 2) will do fine
     
    OnTheVerge likes this.
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    That's much cleaner, but will it multiply the damage too?
     
    OnTheVerge likes this.
  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.