Holding a player in the air for five seconds.

Discussion in 'Plugin Development' started by Huffmanbran, Mar 31, 2014.

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

    Huffmanbran

    I'm currently under a "test" by another developer as my teacher. He is wanting me to complete a fun little test to see if I'm worthy. I've gotten stuck on one step. I'm supposed to send a player in the air x amount of blocks high, I did that already. However when the player reaches the maximum point of the launch he wants the player to stay in the air for five seconds.

    How do I hold the player in the air for five seconds?

    Here is my code to execute the launch:

    Code:
    if (cmd.getName().equalsIgnoreCase("pblaunch")){
                Player player3 = (Player) sender;
                player3.setFallDistance(-100.0F);
                player3.setVelocity(new Vector(0, 5, 0));
                player3.sendMessage(ChatColor.RED + "Command not finished.");
    Thank you very much.
     
  2. Offline

    Gamecube762

    Either constantly teleport them, set fly to true on them, or constantly set their velocity.
     
  3. Offline

    Huffmanbran

    Thanks, I should try and set their velocity maybe 5 times...

    EDIT: The velocity timing doesn't work.
     
  4. Offline

    XvBaseballkidvX

    How did you do your velocity timing?
     
  5. Offline

    Gamecube762

    You would want to run a repeating task that sets the player's velocity, or watch the player's move event, check if they are below # on their Y value, set velocity if so.
     
  6. Offline

    MooshViolet

    Huffmanbran Teleport them up in the air, set fly to true to the player, run a runnable for 100 ticks, then set fly to false. This will make them drop to the floor, if that is what you are looking for.
     
  7. Offline

    Maurdekye

    Huffmanbran Make a repeating task that lasts 5 seconds. You'll need to look a the article for Scheduler Programming if you need help with this. Scheduling basically allows you to accomplish the problem you have above; running code after a calculated delay

    And the solution is simple after that, you simply need to constantly teleport the player into a spot in the air.
     
Thread Status:
Not open for further replies.

Share This Page