Slowly changing vector into other vector

Discussion in 'Spigot Plugin Development' started by craterhater, May 18, 2017.

  1. Hey there,

    I am currently working on flying on some sort of object. I got everything to work but I want to change it a little.

    Code (Text):
     setRightArmPosx(a,p.getLocation().getYaw()*-1);
                                     double d = vel.get(p.getName());
                                     a.setVelocity(p.getLocation().getDirection().multiply(d));
                                     
                                     if(a.isOnGround() || getDistanceFromGround(a.getLocation())<3){
                                         if(d > 0.1){
                                             d = d - 0.1;
                                             vel.put(p.getName(), d);
                                         }
                                     }
                                         if(getDistanceFromGround(a.getLocation()) > 3 && !a.isOnGround() && d < 1.4){
                                             d = d + 0.1;
                                             vel.put(p.getName(), d);
                                     }
    This is the code I am using and it doesn't do exactly what I want. This code is inside of a repeating task. I want the object 'a' to slowly change its velocity into 'p.getLocation().getDirection().multiply(d)' instead of jumping straight to it. Anyone got any ideas on how to do this?

    Thanks!
     
  2. You could calculate the new velocity and call that the maximum or something.

    Then divide the maximum by a set value say 30 for example.

    Then each time your task runs add 1/30th (or whatever portion you wish to increase it) of the max velocity until the maximum is reached.


    Sent from my iPhone using Tapatalk
     
  3. Yea but the velocity where it has to go to changes every tick
     
  4. You can't "slowly" change something over the course of one tick. A tick is equivalent to 1/20th of a second.

    If you're wanting something to "slowly" happen it's going to take more than one tick to accomplish.

    Looking at your code. Are you trying to get an armor stand to point to a specific direction or something. Maybe as an object falls?


    Sent from my iPhone using Tapatalk