Change speed of Fireball upon changing its direction

Discussion in 'Plugin Development' started by Irantwomiles, Dec 23, 2019.

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

    Irantwomiles

    I am spawning a Fireball entity at a location and changing its direction to go towards a player, however the fireball speeds up a lot and I can't figure out how to slow it down. Here is what I have tried so far.

    Code:
    Location location = new Location(player.getWorld(), -268, 75, 84);
                Vector vector = player.getLocation().toVector().subtract(location.toVector()).normalize();
                vector.multiply(0.5f);
              
                Fireball fire = (Fireball) location.getWorld().spawn(location, Fireball.class);
          
                fire.setDirection(vector);
    Here is a gif of the fireball for reference.

    Edit: In case you are not familiar with fireball entity, you can not set the velocity.
     
  2. Offline

    KarimAKL

  3. Offline

    Irantwomiles

    I had actually looked at that post, the thing is I'm not launching from a player, but rather a Location. I did fix my issue, but I dont like the method. I had to use #setVelocity() instead of #setDirection(), but the bad part is that I have to constantly update the if I want to to keep going in the direction that I want. I believe the velocity is updated frequently for fireballs on the server side so I need to keep overriding it.
     
  4. Offline

    KarimAKL

    Fireball is still a Projectile either way.

    Seems like a hacky way but, if it works it works i guess. :7
    Though if you're using a runnable for this, i think i'd be better to have 1 runnable for all the fireballs instead of 1 for each fireball. (I'm no expert on performance though)
     
  5. Offline

    Irantwomiles

    Yea I did do that. Though I don't like how I have to update it every 1/20 of a tick.
     
Thread Status:
Not open for further replies.

Share This Page