Boat Velocity Not Showing?

Discussion in 'Plugin Development' started by Joey402MC, Aug 3, 2017.

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

    Joey402MC

    Basically, it says the velocity of the boat is changing, but the boat does not move.

    I even went to some drastic measures here to test it out, still not moving:

    Code:
    Boat b = (Boat) e.getPlayer().getVehicle();
                            b.setWorkOnLand(true);
                            b.setMaxSpeed(5000000);
                            if(b.hasGravity()) {
                                b.setGravity(false);                          
                            }
                            b.setVelocity(b.getVelocity().add(new Vector(50,50,50).multiply(50)));
                            b.getPassenger().sendMessage(b.getVelocity().add(new Vector(50,50,50)).multiply(50).toString());

    The message it is sending to me: 127500.0,127500.0,127500.0

    Boat still isn't moving.

    What am I missing here?

    Thanks!
     
  2. @Joey402MC
    b.getVelocity() returns a clone (or actually it creates a Vector object, but same principle) of the entity's velocity, so anything you do to the returned Vector object will just be ignored. You have to use the b.setVelocity() method.

    EDIT: Pardon my stupidity, didn't read you code properly. To test whether a velocity is actually being set, print out b.getVelocity() without making any modifications to the returned Vector object.
     
  3. Offline

    Joey402MC

    Well now it says the velocity is 2500,2500,2500. Still no movement though.
     
Thread Status:
Not open for further replies.

Share This Page