• Hey! Register here to create your account, engage with the community, and talk about what is new!

how to make an entity take damage from a raycast

woodpeckercity

New member
Joined
Aug 30, 2023
Messages
4
Reaction score
1
I am making a game where you fight large amounts of enemies with my freinds, and im trying to make a magic missle attack where i look at a target and then they take damage. How do i make this work (i have tried a few things)
 
Solution
You need to use Select Object: Filter Selection -> Filter Ray. It's a filter ray so it only affects the stuff that were previously selected. To use it:

Place a Select Object -> Create Selection -> Entity By Condition: If Entity Is Mob. That selects all mobs. Now, place a Select Object -> Filter Selection -> Filter Ray, in its first slot, place a variable (preferably a LOCAL one), this will give us the hit location (so we can summon a particle at that location), let's call it HitLocation for now. in the 2nd slot put a Game Value -> Location Values -> Eye Location of the default player so the raycast starts from your eye. In the 3rd slot, put a number that will represent the max distance in blocks. in the...

ARMcPro

Forum adept
Overlord
Joined
Oct 20, 2020
Messages
1,260
Reaction score
356
You need to use Select Object: Filter Selection -> Filter Ray. It's a filter ray so it only affects the stuff that were previously selected. To use it:

Place a Select Object -> Create Selection -> Entity By Condition: If Entity Is Mob. That selects all mobs. Now, place a Select Object -> Filter Selection -> Filter Ray, in its first slot, place a variable (preferably a LOCAL one), this will give us the hit location (so we can summon a particle at that location), let's call it HitLocation for now. in the 2nd slot put a Game Value -> Location Values -> Eye Location of the default player so the raycast starts from your eye. In the 3rd slot, put a number that will represent the max distance in blocks. in the 4th slot put a number that will indicate the width, putting larger numbers will allow the player to hit the mobs easier. And lastly in the 5th slot, put a number that will indicate how many mobs it pierces (and damages), a Number 1 would only damage 1 entity.

Now your Selection Target is the mob(s) that you hit, you can place an Entity Action: Damage, Shift-Right click the sign of it and click Selection (so you change the target of the code block), and put a number of your choice in the chest that indicates the damage (in half hearts, so a number 2 = 1 heart). And you can place a Player Action: Particle and spawn particles with the HitLocation variable as the location parameter.
 
Solution
Top Bottom