Posted January 25, 20223 yr Hello, I created a custom entity which shoots snowballs at the player and other mobs. Now I want it to look at the target while doing so --> rotating its head to it/at least rotate its body in the targets direction I tried to use this.lookAt(enitity) which doesnt seem to work. Spawning Particles doesnt work either public void tick() { this.attackTimer++; LivingEntity targetentity = this.snowmanCannon.getTarget(); this.snowmanCannon.setAttacking(true); Level level = this.snowmanCannon.level; this.snowmanCannon.getLookControl().setLookAt(targetentity); if(!this.snowmanCannon.hasLineOfSight(targetentity)) { } else if (this.attackTimer == 1) { this.snowmanCannon.setAttacking(true); Vec3 pos1 = this.snowmanCannon.getEyePosition().add(0,-0.5,0); Vec3 pos2 = targetentity.getEyePosition(); Vec3 dir = pos2.subtract(this.snowmanCannon.getEyePosition()); SnowmanCannonProjectile snowball = new SnowmanCannonProjectile(level, pos1.x, pos1.y, pos1.z); snowball.shoot(dir.x, dir.y, dir.z, 4.5F, 0.1F); this.snowmanCannon.playSound(SoundEvents.SNOW_GOLEM_SHOOT, 1.0F, 1.0F); level.addAlwaysVisibleParticle(ParticleTypes.EXPLOSION, pos1.x, pos1.y, pos1.z, 1d, 1d, 1d); level.addFreshEntity(snowball); } if (this.attackTimer == 3) { this.snowmanCannon.setAttacking(false); this.attackTimer = 0; } } Thank you for any help
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.