#Despawn mob when you look at him
1 messages · Page 1 of 1 (latest)
easiest way is to use scripts
use the getEntitiesFromViewDirection() method on the player
do you have any experience with scripting?
You could do:
/execute as @a at @s positioned ^^^100 run event entity @e[r=99.9] <your event for despawn>
So using functions right?
ye
No I'm not
its kinda easier since its just 1 command lol, no need scripts for that
but if you want i can use scripts
I was looking into some addons and saw that some of the use functions and dummy to call the despawn event to the mob
thats what it does
just add type= in the event so itll affect just your entity
So how can I make this function work properly in my mob without affecting other mobs? Should I call it in the behavior
do you have a event with minecraft:instant_despawn component?
Still no
Yes
So I may add the despawn component and force it to trigger
When i look at the entity
ye, and execute the event in the entity that is in front of you
Oh alright ty, I'm pretty sure I need put it in the tick.json to keep working
Thanks I'll try it later I'm a bit busy rn but I can ping you if an error occurs if you don't mind being pinged
ye
sure
SCRIPT VERSION
-# if you wanna use it
import { world, system } from "@minecraft/server";
system.runInterval(() => {
world.getPlayers().forEach((player) => {
player.getEntitiesFromViewDirection({
type: "prefix:yourentity"
}).forEach((e) => {
const entity = e.entity;
// this is the event to despawn the entity
entity.triggerEvent("your:event_to_despawn");
});
});
});
@short night if you wanna use scripts...
Oh thank you so much I'll try it later!
just use the lookat component to call an event that adds the despawn component in a component group
You guys are wild haha
lookat is definitely a good option, but it only works when you look at the entity's head
if you were to use that command, wouldn't it get all entities in this giant circle?
ye
Yes i tested the script and the lookat behavior, the script didn't worked bc he says that I'm using 1.0.0-beta? And says that I need choose another version
That's why I also gave the script option
Lookat looks very fine since the entity it's humanoid
then you should try it
Already did it, it's working fine
nice
you should use 1.11.0 or 1.12.0-beta
Just need to manage to learn how to make a entity spawn near to the player and disappear with a timer(it's no hard I mean but I'm a long time without make any addons)
How
change the version in your bp manifest
OH
of @minecraft/server
hmm, i really dk how to do it in the entity file
I think call a function can make it
entity.remove()
does that work with any entity?
yes.
cool
how can I do this
.
im trying to do the same thing without scripts
can you explain to me