Sending a fireball to someone

Discussion in 'Plugin Development' started by Gravious, Aug 31, 2012.

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

    Gravious

    Hello,

    How do I send a fireball entity from one location to another? It has to hit the block at that exact location.

    This is the code I currently have:
    Code:
    // et = a player entity
    Location loc = et.getLocation(); loc.setY(loc.getY() + 3); // Make the fireball spawn 3 blocks above the player
    Fireball fb = (Fireball)et.getWorld().spawnEntity(loc, EntityType.FIREBALL);
    Vector target = new Vector(); target.setX(pTarget.getLocation().getX()); target.setY(pTarget.getLocation().getY() -1 ); target.setZ( pTarget.getLocation().getZ() );
    fb.setDirection(target);
    
    However, this just shoots the fireball at the same direction every time, which is not the X/Y/Z coordinates of the target player.

    I also tried to launch the projectile at a specific block location, and that didn't work too.
     
  2. Offline

    Giant

    subtract the target location from the current location (or the other way round). So that it becomes:
    Code:
    target.setX(loc.getX() - pTarget.getLocation().getX());
    // etc...
    
     
Thread Status:
Not open for further replies.

Share This Page