Shooting a fireball in a straight line- this should definitely work...

Discussion in 'Plugin Development' started by dibujaron, Jul 28, 2013.

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

    dibujaron

    Code:
    ((Fireball) b.getLocation().getWorld().spawnEntity(b.getLocation(), EntityType.FIREBALL)).setDirection(GunUtils.getFireBallVelocity(playerFacing));
    where b is a Block and GunUtils.getFireBallVelocity(playerFacing) returns a vector that's (0, 5, 0).
    When I run this method, the gun does not always shoot straight. In the trial it's always setting the direction to 0, 5, 0. The problem is the gun isn't shooting straight- it varies much like a dispenser's shot does. It seems to me like setting the direction should make it go the same direction every time- specifically, straight, at a rate of 5. But it isn't. This is sort of important for me, so if any of you know what's up, please let me know! Thanks!
     
  2. Offline

    adam753

    Code:
    setDirection(GunUtils.getFireBallVelocity(playerFacing));
    
    Shouldn't that just be
    Code:
    setDirection(playerFacing);
    
    ?
     
  3. Offline

    dibujaron

    playerFacing is a BlockFace. GunUtils.getFireBallVelocity returns the correct velocity depending on which direction the player is facing. BlockFace.NORTH returns a vector 0, -5, 0. BlockFace.EAST returns 0, 5, 0. etc.

    I'm sure that part works though, because it fires in the proper general direction- it's definitely firing east, just a bit off. The error isn't 90 degrees off.

    Thanks for your reply :)

    anyone? any ideas?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
Thread Status:
Not open for further replies.

Share This Page