I am trying to make TPS game and I want to damage ai or any character with line trace and I search everywhere for this but I can’t find. if you can tell me then plz tell…Thanks in advance
Did you check if your line trace was actually hitting your target? You can debug that in many ways, I like to turn on the debug draw from the line trace and/or watch the value of “Hit Actor”.
I might be wrong, but I’d use “Get Forward Vector” instead of “Get RotationXVector”. I never used that second one actually, but if I understood it, you’re getting the direction of the X axis of the controller.
I also have that kind of similar set up and it looks like this.
This is my line trace. After it hit something I take the Hit Actor and cast it to my character to check if it has indeed hit my character and after validating that I would call the damage function on my Character’s Blueprint (which is S39_Player) and apply damage to that hit character.
I tested the apply damage node in my Project and it worked for me, just add a damage causer in the apply damage node.
to better visualize whats going on - set the debug trace to frame or duration, also check your boolean hit results before applying damage with an if statement
I problem is solve. I spawn projectile with line trace and the projectile damage the character and line trace can Also damage character…