How Do You Make TNT Fire Straight?

Discussion in 'Plugin Development' started by Bench3, Nov 29, 2012.

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

    Bench3

    Hi! :)
    How would I make TNTPrimed.class fire in the direction of a player when they fire a bow. I understand how to make it spawn the TNT at this time but how would I make the TNT fire forwards and not upwards when I change the velocity?

    Thanks in advance!
    ~Ben
     
  2. Offline

    bobacadodl

    Apply a vector to it?
     
  3. Offline

    fireblast709

    get the normalized direction the player is looking at
    Code:java
    1. Vector direction = player.getLocation().getDirection().normalize();
    and multiply by a big number
    Code:java
    1. Vector v = direction.multiply(1000);
    Now apply that:
    Code:java
    1. primed_tnt_instance.setVelocity(v);

    And it will go directly in front of you (with the speed of light tho...)
     
    Bench3 likes this.
  4. Offline

    Bench3

    Ok thanks! But why normalise it?
     
  5. Offline

    fireblast709

    to get the unit vector (otherwise you can end up with totally different vectors for each run)
     
    Bench3 likes this.
  6. Offline

    Bench3

    Ok, thanks for your help!!!
     
Thread Status:
Not open for further replies.

Share This Page