Solved Velocity Help

Discussion in 'Plugin Development' started by TGRHavoc, Apr 20, 2014.

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

    TGRHavoc

    So, I'm trying to spawn a Fireball and make it go in the direction that the player is looking... It works... For a second then it changes it velocity so it flies int the +x and +z direction! Any help would be appreciated!

    My attempt:
    Code:java
    1. Vector dir = player.getLocation().getDirection();
    2. Location loc= new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY() + 4, player.getLocation().getZ());
    3.  
    4. Entity fireball = player.getWorld().spawnEntity(loc, EntityType.FIREBALL);
    5. fireball.setVelocity(dir);
     
  2. Offline

    zDylann

    Well if all you want to do is shoot a projectile where the player is looking then use:

    Code:
            Fireball fireball = player.launchProjectile(Fireball.class);
    If you are not using the variable later then just use player.launchProjectile(Fireball.class);
     
    TGRHavoc likes this.
  3. Offline

    TGRHavoc

Thread Status:
Not open for further replies.

Share This Page