Launch Entities

Discussion in 'Plugin Development' started by KingFaris10, Apr 21, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    KingFaris10

    Hi, I'm trying to launch an entity not too high, just like a knockback. I've tried (even thought it'd obviously not work)
    Code:
    event.getEntity().setVelocity(event.getVelocity().multiply(3));
    That doesn't work. I really need help, thanks. If it's possible to make it so it's not only a Player, but ANY entity.

    Nvm, it does work, it's just a really bad power. I need to do:
    Code:
    .multiply(100));
    to make it visible.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  2. Offline

    lenis0012

    Im not sure if this works, but you can try

    Code:java
    1. Entity entity = event.getEntity();
    2. Vector dir = enttiy.getLocation().getDirection();
    3. dir.add(0.0D, 2.0D, 0.0D); //2.0 --> upwards shooting
    4. dir.multiply(2); //speed
    5. entity.setVelocity(dir);


    Your code will make the entity go weird.
    When the modX is higher than 1 it will be 100/
    And the entity wll be waliing as soon as its on the ground again.
    Better to use .add and apply smaller changes to the multiply function
     
    ProMCKingz and microgeek like this.
Thread Status:
Not open for further replies.

Share This Page