Started by
moffmoth1
on
Topic category: Help with MCreator software
Hello!
I have my code set up so that, upon a custom entity spotting a player and choosing to attack, it plays a sound. However, it rapidly plays it as long as it's attacking the player and I can't seem to make it stop. I want it to only happen once per player it attacks.
First calculate the length of the sound in ticks, then in the same procedure add the blocks - wait <#> ticks, and insert <execute command [stopsound ... your_custom_sound}
I have three sounds in the soundbank for it. I want it to only play once per time the entity sets its sights on a player. Something like this:
Entity sees Player
Entity plays sound once
Entity is hit by skeleton, changing attack target
Entity does not play sound
Entity kills skeleton
Entity re-sees Player
Entity plays sound once
I have it working, except the sound plays each tick that the entity has its eyes on the player.
Have an nbt that turns to true if it is focused on player, and false if it isnt. If focused on the player, play the sound then turn it true.
Like this? Because still no luck.
Update! I got it working, it just doesn't re-play the sound if the entity changes targets and then back to the player. Still! This is great!!