TransWikia.com

How do I teleport a player when a mob gets close?

Arqade Asked on April 13, 2021

I want to make it when a zombie comes within 1 block of me I get teleported somewhere. I want to do this with 1.16.2 command blocks.

I don’t know how to do this yet, but I only need the command, not the explanation.

One Answer

Since you did not provide details to where you are going to be teleported, I will provide some examples.

Baseline command:

/execute as @a at @s if entity @s[distance=0..1, type=zombie] run tp @s x y z

Assume your "safe house" is at coordinates 0 64 0. Replace x y z with 0 64 0, so the player will be teleported to 0 64 0 if a zombie gets too close to a player.

You can also use tilde and caret notation. More information about that can be found here. To teleport the player 10 blocks forward, use ^ ^ ^10 instead of x y z.

I hope this helps. Comment down below if there are any issues with this solution.

Answered by fasterthanlight on April 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP