About 'Make Our Attackers Attack'!

In this video (objectives)...

  1. Create a new attack animation for our Lizard.
  2. Create attack method and collision event to change animation state.

After watching (learning outcomes)...

Transition our attacker's animation state to attacking when they collide with a defender.

(Unique Video Reference: 37_GL_CUD)

We would love to know…

  • What you found good about this lecture?
  • What we could do better?

Remember that you can reply to this topic, or create a new topic. The easiest way to create a new topic is to follow the link in Resources. That way the topic will…

  • Be in the correct forum (for the course).
  • Be in the right sub-forum (for the section)
  • Have the correct lecture tag.

Enjoy your stay in our thriving community!

Hi Rick

Quick item.
In a previous video you tweaked the defender box colliders to fill the whole block to intercept click so we could not place more than one defender per square.
In this video you are tweaking the colliders again to let the attackers get closer. Would this not open us up to problems with double placement of defenders again.

Could it possibly be better to prevent double placements in code?

Maybe something like this in the coregameArea script

 bool squareAvailable(Vector2 spawnPosition)

    {
foreach (Defender defender in FindObjectsOfType<Defender>())
        {
            Vector2 defenderpos = defender.transform.position;
            if (defenderpos - spawnPosition) {
                return false;
            }
           
        }

        return true;
}
    

This could be called after the snapping function is called. Since all the defenders are snapped the coordinates should line up precisely.

I am editing this because I may have gone for the overly complicated solution. What if I just make the box collider on my attacker smaller and keep the defender collider filling the whole block? like this.
image

1 Like

I really like that you’re thinking about this and not just doing what I’m doing! There are a few ways to approach this. I tend to go for the simple way until the simple way breaks. So, if you find that it breaks, adding some code to protect against this is a great idea.

Privacy & Terms