About 'Conditional Instantiation'!

In this video (objectives)…

  1. Recap our design decisions for Waypoint.cs
  2. Add the ability to flag a block as "placeable"
  3. Use version control to find a bug we introduced
  4. Differentiate between valid and invalid tower clicks.

After watching (learning outcomes)…

How to filter click input based on data about what's being clicked-on.

(Unique Video Reference: 29_RR_CU2)

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!

When doing the refactoring for the “SetAsPath” method, you made a change that alters the functionality of the pathfinder such that the first time it runs it adds the previous.exploredFrom waypoint instead of adding just the previous waypoint. This will visually break the path, but not the script as the script will now just skip the next to last waypoint.

How it appears at present:
while (previous != startWaypoint)
{
previous = previous.exploredFrom;
SetAsPath(previous);
}

This is corrected by moving the “SetAsPath” back above the “previous = previous.exploredFrom;” Thus:
while (previous != startWaypoint)
{
SetAsPath(previous);
previous = previous.exploredFrom;
}

Thanks for sharing. Please use code formatting when sharing code to make it easier to read

It feels a bit weird to me blocking tower placement along the shortest path. From the player’s point of view, there is nothing distinguishing the blocked waypoints from the ones that towers can be placed on.

My approach was to simply make a different type of tile where towers are placeable. I used neutral tiles for this. However, if you want to make the towers placeable on the waypoint tiles, I think the path needs to be calculated dynamically. This would mean placing a tower on the waypoint would only be blocked if doing so would stop the enemy from reaching your base. So if you place a tower on the current shortest path, I think it would feel more natural for the enemy path to be re-calculated, and if no path exists then it would block the tower placement.

3 Likes

Privacy & Terms