#how to make entities execute an event when they've been hit with a projectile,
1 messages · Page 1 of 1 (latest)
Once you have finished, please close your thread.
You can have an on_hit event on your projectile, that runs an execute command to run whatever it is that you want on the entity. If you're wanting to detect all projectiles though, there's some things you could do with damage sensors on the entity checking for specific sources, which would probably work out better, less janky and more consistent. You should be able to detect the entity type that caused damage, and then run an event with your command in it.
@wraith ember, see this here:
https://wiki.bedrock.dev/entities/entity-events.html#targets
is the damage sensors effected by I-Frames
immunity frames
It might be. I don't know exactly what you want to achieve.
There are a lot of solutions, but they're all contextual.
basically I want to make a custom health with scoreboards, because I'm trying to make a health system for my project that doesn't rely on minecraft's i-frames
Ah, alright. You'll want to have the events running from the projectile in that case. Let me find some more links.
This means you'll need to have this on all projectiles though, vanilla and custom.
not using any vanilla projectiles in my project
also pvp is not apart of my project, only pve
Alrighty. That's less work for you then.
Ah, so you're familiar with the projectile component then, right?
sort of
https://wiki.bedrock.dev/documentation/projectiles.html#on-hit
See this section of the Wiki page.
The best way of handling this is to trigger an event on the projectile's target. It should be pretty consistent. The event with the command will be then be in your entity file, and won't have any chance of being weird if you have a group of entities are huddled in a group around the entity that gets hit.
still not sure what code exactly I need to add
Well, I don't know what you have at the moment, so I couldn't tell you.
"on_hit": {
"remove_on_hit": {
},
"impact_damage": {
"damage": 0,
"knockback": false,
"semi_random_diff_damage": false,
"destroy_on_hit": false
},
"definition_event":{
"affect_projectile": true,
"event_trigger":{
"event": "pvz:peahit",
"target": "self"
}
},
"arrow_effect": {}
},
that
Are you prepared to add events to all of your entities so that they can have the command run using non-jank methods?
by entities do you mean projectiles or actuall mobs
mobs
"on_hit": {
"remove_on_hit": {},
"impact_damage": {
"damage": 0,
"knockback": false,
"semi_random_diff_damage": false,
"destroy_on_hit": false
},
"definition_event": {
"affect_projectile": false,
"affect_target": true,
"event_trigger": {
"event": "pvz:peahit"
}
},
"arrow_effect": {}
}
You'll use this on your projectile, it should trigger any event named "pvz:peahit" on the entity that it hits.
But you'll need to create this event in each of your mobs.
Are you familiar with running commands from events?
"affect_affect_target"?
yea doesn't seem to work
@steel orchid yea I did Everything you told me too and it's not working, I tried running a command that makes the entity take damage and it works but the projectile for some reason just can't seem to do it