Ignoring Dead Enemies

Dead enemies aren’t worth stressing about, don’t let them get under your skin. :slight_smile:
Any questions or comments about this lecture?

Interesting choice to add another method for this issue, Did you guys consider just setting the collider.enabled to false? Can do the same with the NavMeshAgent and then you can just walk on the dead body :stuck_out_tongue: but atleast without the collider you cant raycast it.

1 Like

Yep, we considered that. We like the realism of needing to walk around the bodies and not clipping straight through them. Also, we need some way of being able to click on them to get loot.

1 Like

After toying with that simple fix a bit, I decided on pretty much the same conclusion. My thought process was like, well I could make a vanish in X amount of seconds method and then spawn in a loot bag…but that just kept going down the rabbit hole, I settled on the CanAttack() as well.

Cool. And yeah, depends a lot on what behaviour you want. We want our enemies to stick around and be on the ground even if we go off to another level and come back… kinda grim but I think makes for a more entertaining journey if we have the player coming and going through the same areas.

Needs more blood particle effects! Lol, anyhow awesome I am enjoying the remake so sally fourth and carry on Sir Peasant of Knights!

1 Like

Animation wont play on duplicated objects(AKA Control + D). Just in case someone runs into the same problem. (Unity 2018.3.5f1)


Powered by TinyTake Screen Capture

Video: https://fernandof.tinytake.com/sf/MzQyNjA0M18xMDI1MzQ3MA

1 Like

While not specifically covered in this lecture I noticed a bug while working on it. In order to replicate the problem you were covering I added multiple enemies as you did. What I have found is that if I place one enemy behind the other, when I click on the closer in order to attack , my character runs straight past it to attack the one behind. I believe it’s an issue in the InteractWithCombat method but can’t seem to locate where the issue lies.

I have the same issue. Have you figured out a fix to this? I’ve been trying my best to fix this issue. My guess is that the code within InteractWithCombat cycles through all objects hit by the Raycast, finds all objects with CombatTarget, but only acts on the last object in its list. I think we can fix this if we stop iterating through the objects hit by Raycast once it finds the first object with a CombatTarget component. I’m not sure if they tackle this bug in future videos so I didn’t spend too much time trying out my idea.

I’m facing some kind of a bug and i can’t resolve it
when duplicating Enemy i get the behavior of some enemies die and other not , although there health is 0 and the trigger is is triggered but the animation not didn’t work. even when i try it manually. can someone explain why this behavior is happening.

And extra work how to add arrow shooting effect, I’ve searched and couldn’t find any help.

I did that challenge that way before watching the hints, tested it worked, patted myself on the back for being clever, and then when the instructions came out, I was somewhat lost on why we would be doing it that way. After reading Rick’s input, it makes sense, and I am learning a lot about coding by trying different approaches. I had two questions in different directions. 1. Would it be possible to reenable the collider to block raycasting later if you kited enemies into a choke point(ie, hide behind the pile of bodies)? 2. How would you go about setting up a despawn timer for the bodies?

I had the same bug. Actually, I did not solve it with duplicate, instead just dragged them from the Prefab folder, and worked perfectly.

@Rick_Davidson I have a question - is there any point in checking null on CombatTarget and null on Health if we are guaranteed that CombatTarget forces the use of Health (via RequireComponent)?

obraz


Proposed solution:
obraz

Return target will ensure that false is returned if CombatTarget is null, and we will only go to the second condition if we get true in the first. If the character is alive, we will return true (in my case I used IsAlive instead of IsDead).

Isn’t the proposed solution better / more readable?

Best regards,
Peter


I have a problem. This my Combat Raycast code. My scene has 3 enemy, When I hit one of them, Player went to enemy, animation was started,enemy was died but After that I clicked another enemy body my player didn’t do anything. I clicked anywhere my world, where I clicked my player goes to there. Problem is my Raycast code ?

Privacy & Terms