Cast to object

in my ue4 I create blueprint to cast to my AI to set their helth to 0.01 but i didnt know what to link in object and i also dont know how to set “just my charactor can overlapped this blueprint” too help me pls
image

also in my bp that set my ammo to full too i dont know what to cast to

two things before starting on your issue. first learn to use a snip tool or print screen, that picture you took with your phone is horrible, your nodes can barely be read and the filth in the picture is horrible. the second thing is the issue of casting has been answered thousands of times do a bit of searching, ive personally answered this question at least 20 times.

now on to your issue. for the casting to ai to set health, you dont really need this cast if you used the apply damage and event damaged received nodes. if you still wanted to use the cast then you would need to get a reference to the ai enemy to attach to the object pin. to get a reference you could use traces, overlaps, or one of the many other methods (i answered a post on this yesterday).

i dont know what your mean by “just my charactor can overlapped this blueprint”. im guessing you want it so only your character triggers overlap events on a particular actor. if thats the case then theres two solutions, you can either set the collision channels to get it to work, or you could add in a little script that compares the other actor pin to a known actor like say the player character. it would look like event begin overlap-> other actor = get player character ->branch. this would basically tell you if the overlapping actor is the player or something else.

Thanks for answer and sorry for that.but honestly.I still cant fix it.because i dont understand what you want to say.Please explain it easily.because Im newbie of ue4.

what part do you not understand? if you just say i dont get it then what am i meant to do, repeat what i wrote?

the damage part i mentioned can be handled by the two nodes shown in the picture below so you can avoid casting when handling damage. so you could have the apply damage node in the player character and the event any damage on the enemy. lets say you want to apply damage on overlap. in that case you would have (in the player character) event begin overlap then the apply damage node, you would connect the other actor pin to the damaged actor. then in the enemy you would have a the event any damage then you would script health - damage, set health. easy.

253176-capture.png

as far as references go, a reference is a single instance of a actor in the level. so if you had 3 enemies in the level and you wanted to target one particular one you would need a reference to that one. its like telling the game which one to get / target. is you were playing a game and said i want to get an enemy the game wont know which one, thats why you need to tell it explicitly which to target.

as for getting a reference ill link to the post where i explained it all in greater detail yesterday.

the first picture below shows the most basic way to apply damage. when another actor overlaps the character then it applies damage to the other actor.

the second picture shows how you would apply damage to a health value. when any damage comes in then it just gets the health value and subtracts from it the damage, then sets the health variable.

253177-capture.png

Thanks for Answer That’s help a lot XD