Adjusting spawned Fireball speed

Discussion in 'Plugin Development' started by Cryptite, Feb 4, 2014.

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

    Cryptite

    I have this code which effectively spawns fireballs and shoots them at a target given a source. Problem is that the fireballs are extremely fast and cannot be dodged at all. Try though I might, i've had no luck via combinations of multiply/normalize/etc being able to adjust the speed at which the buggers fly. Anyone had any success with this?

    Here's the code:
    Code:java
    1. void shootFireball(Player p) {
    2. Vector lookat = p.getLocation().toVector().subtract(fireballSource.toVector()).normalize();
    3.  
    4. Fireball fireball = world.spawn(fireballSource, Fireball.class);
    5. fireball.setDirection(lookat.normalize());
    6. }
     
  2. Offline

    xTrollxDudex

    Cryptite
    Multiply the vector by 0.9 or something.
     
  3. Offline

    Cryptite

  4. Offline

    travja

    Try multiplying it by more that 1
     
  5. Offline

    xTrollxDudex

  6. Offline

    Cryptite

    travja
    Multiplying by more than 1 also doesn't seem to effect the speed... :/

    xTrollxDudex
    No luck. Seems as though using setVelocity without setDirection and the fireball doesn't shoot at all.
     
Thread Status:
Not open for further replies.

Share This Page