Hello, I have been trying to make my boss move smoothly for the last 10 hours and i've finally decided to ask for some help. I am trying to get my boss to sprint/walk to a viewer in 5 blocks range, attack the player, and also look at the player.(I have the range down and the attack). I've heard that i need to use Sin/Cos/Tan but i dont know how to apply that to my php coding. PHP: foreach($this->entity->getViewers() as $viewer) { if ($viewer instanceof Player) { if ($viewer->distance($this->entity->getPosition()) < 5) { $attackdamage = mt_rand(1, 20); $ev = new EntityDamageByEntityEvent($this->entity, $viewer, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $attackdamage); $viewer->attack($ev); } }} Thank you for your time.
Doesn't seem like that code will move the entity. Also, try focusing more on what you can do, and ask for help on new things.
I recommend taking a look at how the AI driven mobs from PEX or VanillaEntityAI function. Can give you a hint probs.
For very simple moving you might want to check out https://github.com/diamond-gold/MiniBosses/blob/master/src/MiniBosses/Boss.php#L238
ok i was reading it and this part started to mess with my brain. PHP: if($x ** 2 + $z ** 2 < 0.7){$this->motion->x = 0;$this->motion->z = 0;} else{ Can someone explain?
I understand slightly more now. I decided to open Notepad and start writing down what everything is doing. This is what I have so far Code: Players X = 30 Players Y = 38 Players Z = 82 Boss X = 25 Boss Y = 40 Boss Z = 80 PX Away From BX = PX - BX (30-25)[5] ($x) PY Away From BY = PY - BY (38-40)[-2] ($y) PZ Away From BZ = PZ - BZ (82-80)[2] ($z) if $x * $x + $z * $z less than 0.7 then dont move else the amount of blocks away is absoulte value of $x + $y ($diff) $diff = 7 move the boss's x at 1 * 0.15 * ($x / $diff) [Motion: 0.10] {Player Is Too Close But Not Close Enough For Boss Not To Move} Am I Basicallly Correct So Far?