3

I've seen this question answered before for Java, but I haven't found a Bedrock answer. I need this for a lot of projects, but for the sake of this, let's say I'm making a turret. The turret is controlled by an invisible armor stand called "turret", and summons bullets which are also invisible armor stands named "bullet". I can't, however, figure out how to get the bullets to move in the direction they're facing. Here's the syntax I have: /execute as @e[name=bullet] run tp @s ^ ^ ^1 I presume this would work in Java, and I remember this syntax working before, but I believe it was the change of the Bedrock /execute syntax that made it stop working. How would I properly make an entity move forward?

1
  • MCBE probably has the entity selector argument for facing direction. You can provide lots of small ranges and calculate the sine/cosine values yourself. Commented Dec 18, 2023 at 20:37

2 Answers 2

0

/execute as @e[name=bullet] at @s run tp @s ^^^1 should work.

If we walk through the command, execute as @e[name=bullet] makes all of the entities named “bullet” (armor stands in this case) individually run the following commands as themselves, so all @s selectors after the as only target the stand running it. However as doesn’t change the position or rotation of the command, but at does. So at @s sets the position and rotation to the stand running the command. And lastly, run tp @s ^ ^ ^1 teleports all the stands one block in the direction they are facing.

0

/execute at @e[name=bullet] as @e[name=bullet] run tp @s ^ ^ ^1 will work, but only with one armor stand. as doesn't change position, rotation, or dimension, only who/what is executing it. at changes position, rotation, and dimension, but not who or what executes it. The problem with multiple armor stands is each one executes in order, so stand #1 teleports all bullets 1 block in front of it, then stand #2 teleports all bullets 1 block in front of it. The Wiki explains more in depth here: Subcommands and forking

Edit: a comment responded with a fully functional command, so that is in the next answer.

7
  • Possibly /execute as @e[name="bullet"] run execute at @s run tp @s ^^^1? Commented Mar 13 at 19:11
  • @Hipposgrumm yes, that does work. Will edit now.
    – Ekipsogel
    Commented Mar 18 at 18:53
  • @Hipposgrumm actually, looking at it closer, the quote marks and “run execute” aren’t necessary.
    – Ekipsogel
    Commented Mar 18 at 19:19
  • actually, the run execute is what makes it work. However yeah I don't think the quotes are needed unless the name has a space in it. Commented Mar 18 at 21:19
  • No, quote from the wiki: Note that ... run execute ... has no effect at all in both Java Edition and Bedrock Edition. For example, the following commands work the same: execute as @e[type=armor_stand] as @e[type=armor_stand] run summon armor_stand execute as @e[type=armor_stand] run execute as @e[type=armor_stand] run execute run execute run summon armor_stand
    – Ekipsogel
    Commented Mar 19 at 13:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .