**TLDR: Playing an animation of a 1P arm swinging with a knife attached at the socket wont produce hit events cant check tag, cant check == object cant get all actors of class and check index = object. I’m trying to setup so that the player (first person) can equip a bladed weapon and chop down trees. ** If I use the stock 1P template to shoot the trees, it works fine. When I use my own 1P skeletal mesh to swing a knife spawned at a socket for it, and then transformed every tick to that socket transform it doesnt generate hit events.
I created a socket on the wrist of my 1PMesh skeletal mesh skeleton. Then in its blueprint I added static mesh ‘Knife’ and in the construction script created AttachTo(Mesh1P[Socket_Hand.R], Knive) . I then just tested it out by setting it to a knife mesh. It plays fine the animation and the knife swings.
I set OnComponentHit(Knife) to print “Hit event” and set health -= 0.1 and set the collision to “Block All” all other settings are stock.
Then I took a tree static mesh and turned it into a BP. In this BP I added OnComponentHit(StaticMeshComponent) to check if what hit it was a knife by breaking the hit result and checking if hit actor was the knife (which was done by casting on EventBeginPlay GetPlayerCharacter(FirstPersonCharacter) and promoting that to a variable called 1PChar. Then taking 1PChar, getting ‘Knife’ and doing a ObjectEqual(HitActor, Knife) conditn into a branch. False goes “Hit event, but not knife”, True plays a sound and prints a message ‘"Tree Hit At: " [Hit.ImpactPoint]’
I’m not getting any HitEvents… Overlap events work just fine. My character mesh gives a “Hit even but not knife” message (false path).
My partner tried setting up custom collision channels one for the Knife one for the Tree. The Knife and Tree channels both default to Overlap in the project settings (tried Block too) which means the Tree ignores everything but overlaps the Knife channel (tried block too), and on the inverse, the Knife overlaps (again tried block too) only the tree.
So overlap events work but not OnComponentHits.
Any ideas? I had success with simulating physics, but then it was generating hit events and I had no way to keep the static mesh well… static. Trying to set its transform to the transform it has on eventBeginPlay() made it jiggle till its health ran out and thus got destroyed.
I’ll edit with some pics in a second.
Any help would be great, this is blocking progress in our project.
First person character construction script to set the Knife SM to the Mesh1P socket for it
First person character event graph (My partner was trying overlap events instead, but its the same setup, I just used OnComponentHit before)
I should add. If I spawn the knives and shoot them using the stock 1PChar template, it hits fine as long as I create an empty blueprint for the Knive.
Edit: So I tried this and it still doesnt regognize a hit of the animation playing with the knife in the hand. I spawn a BP of the SM of the knife on EventBeginPlay() of my character at the sockets transform then on EventTick() I set worldtransform of the knife to the sockets world transform.
Then in the tree on EventHit() I get all actors of class into a ForEach loop which prints that it found a knife at index [x] and then branches if Other (actor) is = to array element.
My character still creates the false loop “Hit by something else” but no trues.