1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How can I push a player forward?

Discussion in 'Development' started by Draglor56, Apr 6, 2020.

  1. Draglor56

    Draglor56 Silverfish

    Messages:
    24
    I want to push a player forward, but I dont now how?
     
  2. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    189
    GitHub:
    ethaniccc
    You can use setMotion to push a player foward
    PHP:
    $player->setMotion(new Vector3());
     
  3. Draglor56

    Draglor56 Silverfish

    Messages:
    24
    Yes I know but how?
     
  4. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    PHP:
    $player->setMotion($player->getDirectionVector()->multiply(2));//set 2 to whatever amount of force you want to apply to the player
     
    ethaniccc likes this.
  5. Draglor56

    Draglor56 Silverfish

    Messages:
    24
  6. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    189
    GitHub:
    ethaniccc
    I want to push the player and make them go up at the same time, how would you do that?
     
  7. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Set the motion's y to a positive value
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.