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

Entity movement

Discussion in 'Development' started by Mr174, Feb 21, 2019.

  1. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    I want to learn how to make an entity walk back and forth, does anyone have any examples?
     
  2. YarkaDev

    YarkaDev Spider

    Messages:
    9
    GitHub:
    yarkadev
    Well you can send MoveEntityPacket or built-in methods in the Entity class (such as move). If to go, then in the timer or a loop to do it
     
  3. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    No! Do not use packets!

    Yes, they will make entities appear to move on the client, but it does not register on the server that the entity has moved. This can cause all sorts of problems. Do not use packets.

    PureEntitiesX is a pretty good example of how to make entities move.
    https://github.com/RevivalPMMP/Pure...ureentities/entity/WalkingEntity.php#L139L147

    In the given section of the code, the entity's motion is set to move at the designated speed * 1/20 in the target direction. We use 1/20 because a tick is 1/20 of a second and the movement will be reprocessed every tick with the entity's new position data.
     
    Mr174 and HimbeersaftLP like this.
  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.