After implementing the new enemy model, I have double verified that my enemy model has the same components added as the one in the lecture. I am using a different model from mixamo however.
The sphere in my scene still registers hits correctly. The enemy model does NOT. The ontriggerenter never fires when my sword hits it. Sphere does. Enemy model does not.
I note sphere has a sphere collider set to trigger.
I note that enemy model has no collider, though the character controller adds the capsule so that should be all that is needed.
I’ve attached images for reference.
EDIT: If I add a sphere collider to the enemy and set its Is Trigger property to true, my weapon is successfully damaging the enemy now and scoring hits and removing its health. While that feels like I have a workaround, as it is not matching up with the lecture I am left to wonder why I need to add a special collider when the capsule collider of the player control should be working in the same manner.
Just finished the lesson myself and it works fine for me. Can you double-check your prefabs? Maybe you need to push some overrides or check the animations for the enable/disable functions - I played around with multiple animations and realized I was no longer hitting anything, turns out I forgot to add functions to them
Its not the prefabs. I have verified that the weapon collider turns on and off visually as well as through debug logs when it should.
I have verified that the sphere is still damageable. I can strike it and by doing so it damages the sphere.
I have verified that if I add a sphere collider to the NPC enemy and match the player control capsule that the NPC is now damageable so long as the new collider is slightly larger than the player capsule.
I have verified that if I add a capsule collider to the NPC enemy and match the player control capsule that the NPC is also damageable so long as the new collider is slightly larger than the player capsule.
I have verified that without another collider added to the NPC, it does not trigger any response.
I have made the player control capsule around the NPC very large in case it was a matter of the weapon not hitting and that did nothing.
The one key difference in my project vs the lecture is that I am using a different model for the player that has no weapon, so I socket a weapon in and put the collider around that game object. I don’t see why that would make a difference because the sphere collider on the weapon still functions as I expect against everything EXCEPT FOR another player control capsule.
Of interest, when the radius of the new collider around the NPC matches the player capsule, it also will not register a hit. The new collider must be slightly larger than the player capsule.
I’m going to check out a youtube series on creating dark souls with unity to see how he gets around this as his models also do not use built in weapons but have socketed weapons to see what the key difference is.
I also use a different model with a different sword. Here is how my sword setup looks. The Sword game object is parented to the Right Hand Transform. And the Weapon Logic is a separate object Parented to Right Hand Transform. Maybe It helps
I’ve also tried adding the character controller to a new sphere (without a collider) and it works fine for me.
What unity version are you using? I’m on 2021.3 (Apple Silicon version)
Looking at the image, I added a “WeaponSocket” item to the hand, and to that I attached my sword model. Childed to the sword model I attached a game object I call “Sword Collider” which is what he calls “Weapon Logic” in the lecture (I didn’t like how that was named - Sword Collider made more sense to me but its the same thing overall in terms of functionality)
From the screenshot you can see I have mine set up with the Capsule Collider, and the IsTrigger is on. The object is disabled overall because it gets enabled by the animator.
Further up the chain on my Player object I have a Weapon script, which he calls “Weapon Handler” in the lecture. I note your Weapon Damage script is on your weapon itself. Mine is on the player game object.
I note that I’m handling weapon damage in my Weapon class as well as opposed to the Weapon Damage script (I merged the two).
I’ll put the weapon damage script on the weapon itself… I didn’t like how this was split up as it is a bit different to what I’m used to but that may be the source of my issue here.
Yep. My problem was that I was using the on trigger enter at the player level and not the sword collider level. I had mistakenly thought that it would move up the chain correctly.
When I put the OnTriggerEnter on an object at the weapon level, it works fine and I can damage the NPC now.
Thank you for posting your project’s editor, that helped jar me into realizing what the problem was.