Latest / CyberSecurity Summary / Unity Game Development Scripting
Transcript
- 0:00Speaker 1: Welcome to the deep dive. You've given us the source material,
- 0:03Speaker 1: maybe articles, research books, even just your notes, and well,
- 0:08Speaker 1: our job is to dive in and pull out the
- 0:10Speaker 1: really valuable insights, the key nuggets you need.
- 0:13Speaker 2: Yeah, think of us as guides helping you navigate through
- 0:16Speaker 2: all that information. We spot the core concepts, those aha moments,
- 0:21Speaker 2: and you know, the practical takeaways that actually matter.
- 0:24Speaker 1: It's about getting the understanding without wading through absolutely everything
- 0:27Speaker 1: yourself exactly. And for this deep dive, we've got some
- 0:30Speaker 1: really interesting stuff excerpts from a book called Unity Game
- 0:33Speaker 1: Development Blueprints.
- 0:34Speaker 2: That's right, So our mission today is basically to explore
- 0:38Speaker 2: the essential scripting blueprints. This book lays out. These are
- 0:41Speaker 2: like the foundational patterns for building core game features in Unity.
- 0:45Speaker 1: We're looking for the how to and maybe the why
- 0:47Speaker 1: behind things like controls, uy inventory.
- 0:51Speaker 2: AI, scoring, saving games, audio settings, menus, all that core stuff.
- 0:56Speaker 1: It really is like getting a look at the uh,
- 0:58Speaker 1: the engineering dives for how these games are put together
- 1:02Speaker 1: and the source itself.
- 1:03Speaker 2: It comes from place of experience. The author, Kyle Dowst,
- 1:07Speaker 2: his background is in serious games, right.
- 1:10Speaker 1: So that's creating games for things like training or.
- 1:13Speaker 2: Education, exactly, which as a kind of fascinating layer, doesn't
- 1:17Speaker 2: it applying game mechanics to well real world learning.
- 1:21Speaker 1: It does, and the book's reviewers they seem to highlight
- 1:24Speaker 1: the mix of skills needed to you see game DEEV
- 1:27Speaker 1: professor sure, but also web developers, artists.
- 1:31Speaker 2: Miscomposers, aven sell actors and answers mentioned. It just underscores
- 1:34Speaker 2: how game creation is this melting pot of different.
- 1:38Speaker 1: Disciplines, which makes understanding these technical blueprints even more valuable
- 1:42Speaker 1: because while they're the foundation everyone builds on. Okay, let's
- 1:46Speaker 1: dive in, starting with the absolute fundamentals.
- 1:48Speaker 2: Yeah, and you can't get much more fundamental than how
- 1:50Speaker 2: the player actually interacts with the game.
- 1:52Speaker 1: Interactive input Chapter one controls. Why is getting controls right
- 1:57Speaker 1: just so so critical?
- 2:00Speaker 2: Well, it's the player's main connection, isn't it. If the
- 2:02Speaker 2: controls feel I don't know, clunky or unresponsive or.
- 2:06Speaker 1: Just confusing, it breaks the whole experience instantly.
- 2:09Speaker 2: So the book's blueprint starts by saying, okay, decide your
- 2:12Speaker 2: target input device first. Are you aiming for keyboard and mouse,
- 2:16Speaker 2: an Xbox controller, something else? That decision frames.
- 2:20Speaker 1: Everything right, figure out the device, then map the actions
- 2:23Speaker 1: onto it. The blueprint mentions checking Unity's input manager.
- 2:27Speaker 2: Yeah, that's kind of step one. But what's really insightful here,
- 2:30Speaker 2: I think is the focus on customization right from the start,
- 2:33Speaker 2: baking it in.
- 2:34Speaker 1: Ah. So it's not just setting controls, it's building a system.
- 2:37Speaker 2: For setting control exactly. That's the key aha here. Instead
- 2:42Speaker 2: of hard coding, say WES to move, the blueprint is
- 2:45Speaker 2: designed for flexibility. Talks about letting players swap between schemes like.
- 2:49Speaker 1: Their example scheme A and scheme B, maybe WES versus numpet.
- 2:53Speaker 2: Or swapping left and right mouse buttons for attack and aim,
- 2:56Speaker 2: that kind of thing. The point is allowing the player
- 2:58Speaker 2: to choose or change.
- 2:59Speaker 1: Okay, so how does the script blueprint actually handle that flexibility.
- 3:04Speaker 2: Well, the core idea is a dedicated control script, and
- 3:07Speaker 2: inside that script you have variables little containers basically to
- 3:10Speaker 2: hold a specific key or button signment for each.
- 3:13Speaker 1: Action, tailored for different devices.
- 3:15Speaker 2: Right, so you might have a very real PC move
- 3:17Speaker 2: holding WASD and another one like Xbox Move holding left thumbstick.
- 3:22Speaker 2: The script that needs to figure out which device is actually.
- 3:25Speaker 1: Active, and then to make this usable for the player,
- 3:28Speaker 1: you need to show them the current setup and let
- 3:30Speaker 1: them change it, which brings us back to the UI
- 3:33Speaker 1: again exactly.
- 3:34Speaker 2: The blueprint uses unities on UI function for.
- 3:38Speaker 1: This on Uiokay, remind us what's that specifically for some
- 3:42Speaker 1: listeners might not be deep into Unity specifics.
- 3:44Speaker 2: Good point. On UI is a special function Unity calls
- 3:48Speaker 2: for drawing what's called immediate mode UI think buttons, labels,
- 3:52Speaker 2: textboxes drawn directly using script commands rather than building a
- 3:56Speaker 2: UI visually in the editor.
- 3:58Speaker 1: So it's code driven UI drawing called every frame just
- 4:01Speaker 1: for that purpose pretty much.
- 4:02Speaker 2: Yeah, So you use on UI in this blueprint to
- 4:05Speaker 2: display the current control assignments, maybe in an options menu.
- 4:08Speaker 1: Got it, and the script would have functions like the
- 4:11Speaker 1: book mentions, switch profile or switch control scheme.
- 4:14Speaker 2: That you trigger with a button clicking that GUI. Clicking
- 4:17Speaker 2: the button calls the function. The function changes those variables
- 4:20Speaker 2: holding the key assignments, and maybe opens a little pop
- 4:23Speaker 2: up to let the player pick a new key.
- 4:25Speaker 1: It's a neat little system blueprint detect the input, map
- 4:28Speaker 1: it flexibly in variables, display it using on GUI, and
- 4:32Speaker 1: give the player UI buttons to change it.
- 4:34Speaker 2: Precisely a complete loop which.
- 4:37Speaker 1: Leads us perfectly into the next piece. GUI time Chapter two,
- 4:41Speaker 1: moving from player input to the game showing information back
- 4:45Speaker 1: to the player right.
- 4:46Speaker 2: And the book makes a useful distinction here between traditional
- 4:49Speaker 2: two DUI and three dui.
- 4:51Speaker 1: Two d UI being the stuff we usually see flat
- 4:53Speaker 1: on the screen right, health bars, menus, score counters, yep.
- 4:57Speaker 2: The blueprint shows setting up scenes and creating those elements buttons,
- 5:00Speaker 2: health bars, maybe level or XP counters, and again on
- 5:03Speaker 2: GUI is the main function used for actually drawing these
- 5:06Speaker 2: in this particular blueprint.
- 5:07Speaker 1: So for say a health bar.
- 5:09Speaker 2: You'd use something like GUI dot box, which literally just
- 5:12Speaker 2: draws a box, and then you calculate it's within the
- 5:14Speaker 2: script based on like current health divided by maxelf.
- 5:17Speaker 1: So the UI isn't just static art, it's a dynamic
- 5:19Speaker 1: It reflects the game state exactly.
- 5:21Speaker 2: The script does the math, the y does the drawing.
- 5:24Speaker 2: But then there's three d UI, which is UI that
- 5:27Speaker 2: exists inside the three D game world itself.
- 5:29Speaker 1: Like that health bar floating over an enemy's head you
- 5:31Speaker 1: sometimes see.
- 5:32Speaker 2: Perfect example, and the blueprint for that includes a really
- 5:36Speaker 2: neat trick making the UI element constantly look at the
- 5:40Speaker 2: main cameras.
- 5:41Speaker 1: Transform look, so it just turns to face the camera.
- 5:44Speaker 2: Yeah, look, at camera dot Maine dot transform. It tells
- 5:46Speaker 2: that UI element script always rotate yourself so you're facing
- 5:49Speaker 2: the player's view m makes it readable from any angle
- 5:52Speaker 2: in the three D space.
- 5:53Speaker 1: That's clever, handles the orientation automatically.
- 5:55Speaker 2: It is pretty neat. They also show blueprints for things
- 5:58Speaker 2: like three D damage reports you know, the numbers that
- 6:00Speaker 2: pop up when something gets hit. Yeah, yeah, and three
- 6:02Speaker 2: D name tags over characters. For these kinds of dynamic
- 6:06Speaker 2: three D elements, the update function becomes really important.
- 6:09Speaker 1: Okay, and update is different from ANGOI how so yes.
- 6:13Speaker 2: Definitely, Update is a function Unity calls automatically every single frame,
- 6:18Speaker 2: like clockwork. It's where you put game logic that needs
- 6:21Speaker 2: to happen constantly checking for input, moving things around, or in.
- 6:25Speaker 1: This case, making that three D damage text fade out exactly.
- 6:29Speaker 2: You'd use update to manage a timer and maybe decrease
- 6:31Speaker 2: the text self a value its transparency over a second
- 6:34Speaker 2: or two, making it fade nicely.
- 6:36Speaker 1: Okay, so we've got input, we've got output display. Now
- 6:39Speaker 1: what about the actual things the player interacts with? Items, weapons, potions?
- 6:43Speaker 2: Right? That takes us to expandable item classes. Chapter three
- 6:47Speaker 2: and the big idea here is modularity using item blueprints
- 6:50Speaker 2: or classes to avoid repeating code.
- 6:52Speaker 1: So instead of writing totally separate code for a health
- 6:55Speaker 1: potion and I don't know a magic scroll.
- 6:58Speaker 2: You define generic item types that share common features. The
- 7:01Speaker 2: books blueprint breaks them down logically, item self for things
- 7:05Speaker 2: that affect the user like potions, okay, Item way for
- 7:08Speaker 2: close up interaction like swords or wrenches, and item range
- 7:11Speaker 2: for things that shoot projectiles like bows or guns.
- 7:14Speaker 1: That classification makes sense. What kind of information did these
- 7:17Speaker 1: item blueprints hold?
- 7:18Speaker 2: Well? They share common variables things like amount, value, weight,
- 7:23Speaker 2: name maybe a generic stat variable, but crucially they use
- 7:27Speaker 2: enom variables. Enoms remind me an enom or Enumeration is
- 7:31Speaker 2: basically just a pre defined list of possible named values.
- 7:35Speaker 2: So the blueprint uses enoms for the item's action and
- 7:38Speaker 2: its type.
- 7:38Speaker 1: So self action could have values like heel, buff stat
- 7:41Speaker 1: change armor exactly, and.
- 7:43Speaker 2: Self type might be potion, scroll food. The enom tells
- 7:48Speaker 2: the generic item blueprint what kind of item it is
- 7:51Speaker 2: and what it should do when it's used. The script
- 7:53Speaker 2: then has the logic for each of those actions.
- 7:55Speaker 1: Okay, and how does an item actually do something like
- 7:57Speaker 1: healing the player?
- 7:58Speaker 2: How does it communicate The blueprint often uses a Unity
- 8:02Speaker 2: function called send message. It lets one script call a
- 8:04Speaker 2: function on another script just by knowing the function's name.
- 8:08Speaker 1: So the potion script could call a function named say
- 8:10Speaker 1: apply healing on the.
- 8:11Speaker 2: Playoscript precisely send message apply healing amount to heal. It's
- 8:16Speaker 2: a straightforward way for objects to talk to each other
- 8:18Speaker 2: in this blueprint.
- 8:19Speaker 1: Send message seems simple. But could that get messy in
- 8:22Speaker 1: a really big game tracking all those messages.
- 8:24Speaker 2: That's a fair point. It can. For very large, complex projects,
- 8:29Speaker 2: developers often move to more structured systems like interfaces or
- 8:33Speaker 2: event systems for clarity and sometimes performance. But for these blueprints,
- 8:38Speaker 2: send message is shown as a direct functional way for
- 8:41Speaker 2: an item to tell its target, hey, do this.
- 8:43Speaker 1: Got It makes sense for a blueprint approach, and for
- 8:47Speaker 1: items interacting with the world, like melee weapons hitting.
- 8:50Speaker 2: Things that usually involves Unity's physics and collider system. The
- 8:53Speaker 2: blueprint mentions using trigger colliders and the on trigger interfunction.
- 8:57Speaker 2: That function gets called automatically when the items collider marked
- 9:00Speaker 2: as a trigger overlaps with another collider.
- 9:02Speaker 1: So the sword trigger hits an enemy collider right.
- 9:05Speaker 2: And for ranged items, you've also got the projectile's movement.
- 9:09Speaker 2: The blueprint includes a movement type enom for that may
- 9:13Speaker 2: be basic for a straight line, or drop to simulate
- 9:16Speaker 2: gravity with a parabolic arc.
- 9:17Speaker 1: And the item's type enom might affect other things too,
- 9:20Speaker 1: like a potion type usually gets destroyed after one use.
- 9:22Speaker 2: Exactly the blueprint for a potion would likely include a
- 9:25Speaker 2: call to destroy game object after its effect is applied.
- 9:30Speaker 2: The real aha here is defining these reusable blueprints that
- 9:35Speaker 2: you can then configure with different variables in enom settings
- 9:38Speaker 2: to create tons of unique items without starting from scratch
- 9:41Speaker 2: every time.
- 9:41Speaker 1: Okay, so we have blueprints for individual items, but how
- 9:44Speaker 1: does the game keep track of all the items the
- 9:47Speaker 1: player picks up?
- 9:47Speaker 2: Ah? Now we're moving into core game systems like the
- 9:51Speaker 2: inventory chapter four super common, super important in many games.
- 9:55Speaker 1: Yeah, RPGs, survival games, they almost all have one, and
- 9:58Speaker 1: the blueprint seems to cover the essential size limits accessing it,
- 10:01Speaker 1: organizing items, stacking, bartering, dropping using.
- 10:04Speaker 2: This pretty comprehensive system. They outline the implementation blueprint uses
- 10:08Speaker 2: a mix of arrays like in items and lists like
- 10:11Speaker 2: items in item count.
- 10:13Speaker 1: Why both arrays and lists? Oh, what's the thinking there?
- 10:16Speaker 2: Good question? Well, lists are dynamic, right, they can grow
- 10:21Speaker 2: and shrink easily. Arrays have a fixed size once you
- 10:24Speaker 2: create them. Using both might offer some flexibility. Maybe the
- 10:28Speaker 2: array represents the fixed slots visually, while the list holds
- 10:32Speaker 2: the actual items you possess. It depends on the exact
- 10:35Speaker 2: implementation detail. The blueprint also mentions using a placeholder like
- 10:40Speaker 2: an empty object for slots that don't have an item yet,
- 10:43Speaker 2: and a key technique is using key value pair.
- 10:46Speaker 1: Key value pair sounds like storing two related pieces of
- 10:49Speaker 1: info together exactly that.
- 10:51Speaker 2: Think of it as pairing the item data itself, like
- 10:54Speaker 2: health potion with its count like five. So your list
- 10:57Speaker 2: of items actually holds these pairs.
- 10:59Speaker 1: Ah. That makes managing stacks of items like having five
- 11:02Speaker 1: health potions much cleaner.
- 11:03Speaker 2: Definitely, and the core functions in the blueprint reflect this.
- 11:06Speaker 2: There's initialized inventory to set the size, fill slots with
- 11:09Speaker 2: those placeholders, and set counts to zero.
- 11:11Speaker 1: Then adding items add.
- 11:13Speaker 2: To inventory is smart. It first checks do you already
- 11:15Speaker 2: have this item? If yes, just increase the count in
- 11:18Speaker 2: its key value pair. If no, find the first empty
- 11:20Speaker 2: slot placeholder and put the new item pair there, and
- 11:22Speaker 2: removing removed from inventory decreases the count. If the count
- 11:26Speaker 2: hits zero or less. It replaces that slot with the
- 11:29Speaker 2: placeholder again, effectively removing the item handles the stacking logic neatly.
- 11:34Speaker 1: And how does the player actually see and interact with
- 11:37Speaker 1: this inventory? Probably guy again?
- 11:40Speaker 2: Absolutely The blueprint shows integrating this with a guy often
- 11:45Speaker 2: toggled by a key like I. It draws the grid,
- 11:48Speaker 2: the item icons, the counts all based on the data
- 11:51Speaker 2: stored in those arrays and lists. We just talked about the.
- 11:53Speaker 1: Nice self contained system, and it obviously needs to talk
- 11:56Speaker 1: to those item class blueprints we discussed earlier. Yeah, okay,
- 11:59Speaker 1: let's shift focus from the player and their stuff to
- 12:02Speaker 1: well making the world feel less empty, right?
- 12:04Speaker 2: Bringing in other characters with artificial intelligence Enemy and Friendly
- 12:07Speaker 2: AIS Chapter.
- 12:08Speaker 1: Five AI can seem like a black box sometimes. What
- 12:11Speaker 1: techniques does this book's blueprint explore?
- 12:13Speaker 2: It introduces two really common ones, finite state machines or
- 12:17Speaker 2: FSMs and behavior trees. And FSM is like giving the
- 12:20Speaker 2: character distinct modes or states.
- 12:22Speaker 1: Like idle, patrolling, fighting, running away exactly.
- 12:26Speaker 2: The AI is always in one state and rules dictate
- 12:29Speaker 2: when it transitions to another state, like if players cited
- 12:33Speaker 2: switch from patrolling to fighting.
- 12:35Speaker 1: Okay, and behavior trees.
- 12:37Speaker 2: Behavior trees are more like a hierarchy of tasks and decisions.
- 12:41Speaker 2: Think of it like a complex flow charty. Try to attack?
- 12:44Speaker 2: Can I attack? If yes? Do it? If no? Can
- 12:46Speaker 2: I move closer? If yes? Do that? If no? Maybe
- 12:49Speaker 2: weight It allows for more complex sequences.
- 12:52Speaker 1: Of actions, and the book's blueprint uses these.
- 12:54Speaker 2: It suggests you can combine them, which is common. Maybe
- 12:57Speaker 2: use an FSM for the high level state idle, combat, flee,
- 13:00Speaker 2: and then use a behavior tree to define the specific
- 13:03Speaker 2: actions the AI takes within that state.
- 13:05Speaker 1: Ah okay, so you define the states or the decision logic.
- 13:09Speaker 1: What kind of actual actions are these ais performing? In
- 13:11Speaker 1: the blueprint examples.
- 13:13Speaker 2: The book makes a useful distinction between internal actions and
- 13:15Speaker 2: external actions. Internal actions are things the AI does based
- 13:19Speaker 2: on its own state, like following a patrol path, searching
- 13:22Speaker 2: an area if it heard a noise, or decided to
- 13:24Speaker 2: flee if.
- 13:24Speaker 1: Its health is low, and external actions affect other.
- 13:27Speaker 2: Things, yes, like attacking the player, maybe healing an ally,
- 13:30Speaker 2: or interacting with an object. The specific examples mentioned are patrolling, attacking, fleeing,
- 13:37Speaker 2: and searching.
- 13:38Speaker 1: The blueprint also mentions how things happening to the AI,
- 13:41Speaker 1: like taking damage, can trigger changes in its behavior.
- 13:44Speaker 2: Yeah, this is crucial for making AI feel reactive. If
- 13:47Speaker 2: an AI isn't suspicious, it's suspicious variable as false, but
- 13:51Speaker 2: it suddenly takes damage. That event can triggers state change.
- 13:54Speaker 1: So it stops idling and starts guarding searching exactly.
- 13:59Speaker 2: It becomes suspicious behavior blueprint shifts. Maybe it enters a
- 14:02Speaker 2: guard state or a start searching or another example, if
- 14:05Speaker 2: it's health drops below say twenty five percent, a rule
- 14:08Speaker 2: might trigger a transition to the flea state.
- 14:10Speaker 1: Using health or suspicion levels as triggers. Makes a lot
- 14:13Speaker 1: of sense. Now, foreign AI to patrol or flea or search,
- 14:16Speaker 1: it needs to move around.
- 14:17Speaker 2: Pathfinding essential. Yeah, unless your AI just stands still.
- 14:21Speaker 1: Yeah.
- 14:21Speaker 2: The blueprint discusses a couple of approaches. One is a
- 14:24Speaker 2: simple waypoint system, just a list.
- 14:25Speaker 1: Of points the AI walks between.
- 14:27Speaker 2: Basically, yeah, an array of transform objects in unity representing
- 14:31Speaker 2: positions in the world. The AI just moves from one
- 14:35Speaker 2: way point to the next in sequence or maybe randomly.
- 14:39Speaker 1: Okay, simple. What's the other approach.
- 14:41Speaker 2: Using unities built in navmesh system, which is quite a
- 14:46Speaker 2: bit more powerful navmesh.
- 14:48Speaker 1: How does that work?
- 14:49Speaker 2: You essentially bake a navigation mesh onto your level's geometry.
- 14:54Speaker 2: Unity analyzes your scene, the floors, the walls, the obstacles,
- 14:58Speaker 2: and generates a data structure nab mesh representing all the
- 15:01Speaker 2: walkable areas, so.
- 15:02Speaker 1: It figures out where the AI can go precisely.
- 15:05Speaker 2: Then you add a navmesh agent component to your AI character.
- 15:09Speaker 2: This component knows how to read the navmesh and find
- 15:11Speaker 2: efficient paths from A to B avoiding obstacles automatically.
- 15:15Speaker 1: What does baking involve? Is it complex?
- 15:18Speaker 2: You can figure some settings. First, you tell Unity things
- 15:20Speaker 2: about the agent that will use the mesh. It's as
- 15:22Speaker 2: radius so it doesn't scrape walls, it's height so it
- 15:25Speaker 2: knows if it can fit under low ceilings, the maximum
- 15:28Speaker 2: slope it can climb. You can also define off mesh
- 15:30Speaker 2: links manually for things like telling the AI it can
- 15:33Speaker 2: jump across a specific gap or drop down from a ledge.
- 15:37Speaker 2: Then you hit the bake button and Unity calculates it all.
- 15:40Speaker 1: So navmesh handles the complex pathfinding automatically, while waypoints are
- 15:45Speaker 1: maybe better for very specific, predetermined routes.
- 15:49Speaker 2: That's a good way to put it, and the blueprint
- 15:51Speaker 2: actually suggests you can combine them use navmesh for general
- 15:55Speaker 2: get me from here to their movement, but maybe use
- 15:57Speaker 2: waypoints for a strict guard patrol route within an ap
- 16:00Speaker 2: mesh area.
- 16:00Speaker 1: Best of both worlds, right.
- 16:02Speaker 2: And they also mention integrating character animations, which is vital
- 16:06Speaker 2: making the AI visually walk, run, attack, or flee as
- 16:09Speaker 2: its behavior state and navmetch movement dictates. It's not just
- 16:13Speaker 2: an invisible capsule sliding around.
- 16:15Speaker 1: Yeah, brings the character to life. Okay, AI covered. Let's
- 16:18Speaker 1: switch back to the player's side and talk about tracking
- 16:20Speaker 1: progress keeping score chapter.
- 16:22Speaker 2: Six right, Stats and Achievements, giving the player feedback on
- 16:25Speaker 2: how they're doing and goals to aim for.
- 16:27Speaker 1: The source Blueprint lists a solid set of stats to
- 16:30Speaker 1: track kills, deaths, gold, collected gold, spent, level, rounds one,
- 16:35Speaker 1: rounds lost, and.
- 16:36Speaker 2: Then it automatically calculates things like kill death ratio KDR,
- 16:39Speaker 2: when loss ratio WLR, and total time played. Pretty standard
- 16:43Speaker 2: stuff for many games.
- 16:44Speaker 1: How does the Blueprint handle updating these?
- 16:48Speaker 2: It uses functions like a set stat function that gets
- 16:51Speaker 2: called whenever something relevant happens, kill an enemy call set
- 16:54Speaker 2: stat kills current kills plus one, pick up gold, current gold,
- 16:59Speaker 2: current gold.
- 16:59Speaker 1: Plus, and the ratios KDR and WLR.
- 17:02Speaker 2: Those aren't set directly. The blueprint calculates them automatically whenever
- 17:06Speaker 2: the underlying stats kills, deaths, rounds, one, rounds, loss change,
- 17:11Speaker 2: so the ratios are always up to date, inconsistent.
- 17:13Speaker 1: Smart prevents mistakes, and the achievement system builds on top
- 17:17Speaker 1: of these stats.
- 17:17Speaker 2: Yeah, exactly. Achievements are typically tied to reaching certain milestones.
- 17:21Speaker 2: For specific stats, get ten kills, collect a thousand total gold,
- 17:25Speaker 2: reach level five, play for an hour, that sort of thing.
- 17:28Speaker 1: The blueprint mentions tracking progress towards achievements, right.
- 17:31Speaker 2: It suggests using variables like eight kills to store the
- 17:34Speaker 2: player's current count towards the next kill achievement, and it
- 17:37Speaker 2: also uses boollion flags true false variables like get kills.
- 17:42Speaker 1: What are the flags for?
- 17:43Speaker 2: They control whether an achievement can still be unlocked or upgraded.
- 17:46Speaker 2: Maybe there are bronze, silver, and gold levels for kills.
- 17:50Speaker 2: Once you want gold, you set get kills to falls,
- 17:52Speaker 2: so the game stops checking for that achievement.
- 17:55Speaker 1: Ah, okay, So you track progress and have flags for
- 17:57Speaker 1: completion state and displaying this GUI again.
- 18:02Speaker 2: You guessed it. The blueprint involves on GUI or similar
- 18:05Speaker 2: UI functions stat's gui ash gui are mentioned to draw
- 18:09Speaker 2: labels showing the current stat values and maybe icons or
- 18:12Speaker 2: progress bars for the achievements. Using those tracking variables in
- 18:16Speaker 2: flags to decide what to display.
- 18:18Speaker 1: Gives the player that nice visual feedback and sense of accomplishment. Okay,
- 18:22Speaker 1: foundations core systems, but what about making sure none of
- 18:25Speaker 1: this progress vanishes when you quit the game?
- 18:28Speaker 2: Persistence? Creating save and load systems chapter seven absolutely vital
- 18:33Speaker 2: for well most games that aren't just short arcade sessions.
- 18:35Speaker 2: You need to save inventory, stabs, maede, the enemy, positions,
- 18:38Speaker 2: quest progress.
- 18:39Speaker 1: We heard about player prefs earlier for settings, but that's
- 18:42Speaker 1: usually for small bits of data, isn't it. This chapter
- 18:44Speaker 1: seems to go deeper.
- 18:45Speaker 2: It's exactly. Player prefs is great for simple settings, maybe
- 18:49Speaker 2: a high score, but it's not really suited for saving
- 18:51Speaker 2: complex game states. Chapter seven sploes blueprints using two main methods,
- 18:57Speaker 2: flat files and XML.
- 18:59Speaker 1: Files files just simple text files pretty much.
- 19:02Speaker 2: The blueprint shows saving data line by line. You take
- 19:05Speaker 2: your game data, player position coordinates, x, y Z, maybe
- 19:09Speaker 2: their health there ammo count, convert each piece to a
- 19:12Speaker 2: string using toastring, and write each string on a new
- 19:15Speaker 2: line in a text file. Using something called a.
- 19:17Speaker 1: Stream writer simple readable and loading.
- 19:20Speaker 2: Just the reverse. Use a stream reader to read the
- 19:23Speaker 2: file line by line. Then you have to convert each line,
- 19:26Speaker 2: which is text, back into the correct data type integer, float, whatever,
- 19:30Speaker 2: using functions like convert dot two a thirty two or
- 19:32Speaker 2: convert duct single.
- 19:33Speaker 1: And the blueprint mentions deleting the old file first.
- 19:36Speaker 2: Yeah, common practice to ensure you're writing a completely new save,
- 19:39Speaker 2: not appending to or messing up an old one.
- 19:41Speaker 1: What are the downsides of this flat file approach.
- 19:43Speaker 2: Well, it's simple, which is good, but because you're just
- 19:46Speaker 2: reading line by line, you have to know the exact
- 19:48Speaker 2: order that data was saved in. If you add a
- 19:50Speaker 2: new stat later, it can break loading old saves, and
- 19:54Speaker 2: it gets pretty clumsy for really complex nested data like
- 19:57Speaker 2: saving the SATA fifty different enemies.
- 19:59Speaker 1: Which is probably where XML files.
- 20:01Speaker 2: Come in handy exactly. XML provides structure. It uses tags
- 20:05Speaker 2: like HTML to create a hierarchy. The blueprint uses unities,
- 20:09Speaker 2: XML document and XML node classes to build this structure programmatically.
- 20:14Speaker 1: So instead of just lines of values, you have named tags.
- 20:17Speaker 2: Right, you might have a main player data tag and
- 20:19Speaker 2: inside that position X ten y five, Z twenty health
- 20:23Speaker 2: value eighty five, inventory, dot, inventory, and so on. For enemies,
- 20:27Speaker 2: you could have an enemy's tag containing multiple enemy tags,
- 20:29Speaker 2: each with its own position, health, AI, state, etc.
- 20:32Speaker 1: How do you get the data back out when loading?
- 20:34Speaker 2: You navigate the XML structure using the node names. You
- 20:37Speaker 2: find the health node and read its value attribute, or
- 20:41Speaker 2: find the position node and read its xyz attributes, or
- 20:44Speaker 2: you find an enemy node and read its innertext. If
- 20:47Speaker 2: the value is stored directly inside the tag, it's much
- 20:50Speaker 2: more robust for organizing complex data.
- 20:53Speaker 1: A bit more work to set up than flat files maybe,
- 20:55Speaker 1: but more flexible and less prone to breaking if you
- 20:59Speaker 1: change the data structure slightly.
- 21:01Speaker 2: Generally yes. When loading enemies, for example, you loop through
- 21:04Speaker 2: all the enemy nos you find, read the data from
- 21:06Speaker 2: each one, convert it, and apply it to the corresponding
- 21:09Speaker 2: enemy object in your game scene.
- 21:11Speaker 1: And how does the player actually trigger the save or load?
- 21:14Speaker 1: Is it automatic? Manual?
- 21:16Speaker 2: The blueprint can support either. You could tie the save
- 21:19Speaker 2: function to checkpoints the player reaches, making it automatic, or
- 21:22Speaker 2: you could link the save and load functions to keypresses
- 21:25Speaker 2: like F one to save and F two to load,
- 21:27Speaker 2: letting the player do it manually whenever they want. The
- 21:30Speaker 2: functions themselves, just handle the flat file or XML.
- 21:33Speaker 1: Writing reading gives players options for managing their progress. Okay,
- 21:38Speaker 1: we've saved the game state, let's add some life beyond
- 21:41Speaker 1: just visuals and numbers.
- 21:43Speaker 2: Sound oral integration Chapter eight. Yeah, audio is absolutely critical
- 21:47Speaker 2: for immersion and feedback.
- 21:49Speaker 1: What kind of audio blueprints does the book cover?
- 21:52Speaker 2: Well? Adding background music is a big one, and the
- 21:54Speaker 2: blueprint goes beyond just playing one track on loop. It
- 21:57Speaker 2: shows how to set up systems for random music selection
- 22:00Speaker 2: or playlist style systems.
- 22:02Speaker 1: How does that manage?
- 22:03Speaker 2: Usually with a dedicated script, maybe called BEG Music Manager.
- 22:06Speaker 2: It uses Unity's audio source component. That's the thing that
- 22:09Speaker 2: actually plays sounds and holds a list of audio clips,
- 22:12Speaker 2: which are your actual music files. The script then decides
- 22:15Speaker 2: which clip to play.
- 22:16Speaker 1: Next, and you can control things like volume volume definitely.
- 22:20Speaker 2: The blueprint also mentions pitch using a change speed function.
- 22:24Speaker 2: Adjusting the pitch of an audio source often changes the
- 22:26Speaker 2: playback speed too, so you.
- 22:27Speaker 1: Can make the music faster, slower, maybe more tense by
- 22:31Speaker 1: tweaking the pitch exactly.
- 22:33Speaker 2: Then, beyond music, there are atmospheric sounds when rain, bird, song, city, hum,
- 22:38Speaker 2: whatever fits your environment.
- 22:40Speaker 1: How's that handled similar manager script.
- 22:42Speaker 2: Yeah, often an ATM manager script, again using an audio source.
- 22:46Speaker 2: The key distinction the blueprint makes here is between sounds
- 22:50Speaker 2: that should loop continuously like steady rain. It mentions a
- 22:55Speaker 2: play repeat function for that, and sounds that should just
- 22:58Speaker 2: play once when triggered, like distant thunderclap, using a play function.
- 23:02Speaker 1: That makes sense for ambient background noise.
- 23:03Speaker 2: And then the third category is event driven sound effects
- 23:07Speaker 2: or SFX. These are the sounds tied directly to specific
- 23:10Speaker 2: actions or events, like the sound.
- 23:12Speaker 1: Of a sword swing, spell casting, picking up an item, clicking.
- 23:15Speaker 2: A button precisely. These are often triggered by the script
- 23:18Speaker 2: performing the action itself, or sometimes by another dedicated SFX manager.
- 23:23Speaker 1: What if lots of sounds happen at once, like multiple
- 23:25Speaker 1: footsteps or gunshots, the.
- 23:27Speaker 2: Blueprint would likely use a function called play one shot
- 23:30Speaker 2: on an audio source. The cool thing about play one
- 23:33Speaker 2: shot is that it can play multiple clips overlapping on
- 23:36Speaker 2: the same audio source without cutting each other off, so
- 23:39Speaker 2: those multiple gunshots can all ring out together naturally.
- 23:42Speaker 1: Ah okay, So you've got music for mood, atmosphere for
- 23:46Speaker 1: the environment, and SFX for direct feedback, all managed via
- 23:50Speaker 1: scripts talking to Unity's audio components.
- 23:53Speaker 2: Tying it all together and for that final layer of
- 23:55Speaker 2: professional polish.
- 23:56Speaker 1: Game settings Chapter nine. Letting players tailor the experience to
- 24:01Speaker 1: their liking and their.
- 24:02Speaker 2: Hardware absolutely vital, especially for PC games, but increasingly expected everywhere.
- 24:07Speaker 2: Letting players optimize performance and configure things. The blueprint focus
- 24:11Speaker 2: is mainly on video and audio settings.
- 24:13Speaker 1: Okay, video settings, what kind of options does the blueprint cover?
- 24:16Speaker 2: Things like setting the screen resolution using screen dot resolution,
- 24:20Speaker 2: toggling shadows on or off for performance, adjusting the field
- 24:23Speaker 2: of view or FOV, toggling anti aliasing for smoother edges,
- 24:27Speaker 2: setting the sync to match the game's framwrate to the
- 24:29Speaker 2: monitor's refresh rate, and changing overall graphical quality presets like low, medium, high.
- 24:35Speaker 1: Standard graphics options. And audio setting.
- 24:38Speaker 2: Primarily volume controls master volume, but also separate sliders for
- 24:41Speaker 2: the categories we just discussed background music volume, SFX volume,
- 24:45Speaker 2: atmospheric sound volume, and maybe speaker mode configuration.
- 24:49Speaker 1: And crucially, how are these settings saved so the player
- 24:52Speaker 1: doesn't have to redo them every time they launch the game?
- 24:54Speaker 2: Ah, this is where player presss comes back in perfectly.
- 24:57Speaker 2: It's designed exactly for this purpose, saving small bits of
- 25:01Speaker 2: user preference data persistently.
- 25:03Speaker 1: So the blueprint uses player preps set and player preffs
- 25:06Speaker 1: set float, player prefs set string to store the chosen resolution,
- 25:10Speaker 1: volume levels, togble states, et cetera.
- 25:13Speaker 2: Exactly, you save the settings using player prefs when the
- 25:16Speaker 2: player applies changes in the options menu, and you load
- 25:19Speaker 2: them using player prefs, get it, get float, et cetera,
- 25:22Speaker 2: when the game first starts up or when the options
- 25:24Speaker 2: menu is opened.
- 25:25Speaker 1: Okay, so that clarifies the distinction player prefs for small
- 25:28Speaker 1: simple settings data the chapter seven methods flat files or
- 25:31Speaker 1: XML for saving the large complex game state itself.
- 25:35Speaker 2: Precisely that different tools for different jobs, and of course,
- 25:38Speaker 2: to let players actually change these settings, the blueprint includes
- 25:42Speaker 2: building an options menu GUI, probably.
- 25:44Speaker 1: Managed by its own scripts like configure.
- 25:46Speaker 2: Right using standard UI elements. Buttons, sliders for volume toggles,
- 25:51Speaker 2: or checkboxes for on off settings all link to the
- 25:54Speaker 2: functions that change the settings and save them using player prefs.
- 25:57Speaker 1: It's that options menu were all familiar with, but now
- 26:00Speaker 1: we've kind of peaked behind the curtain at the scripting
- 26:02Speaker 1: blueprints that make it work.
- 26:04Speaker 2: Yeah, we've looked at all these different blueprints. In relative
- 26:06Speaker 2: isolation controls UI items, inventory, AI, scoring, saving, audio settings.
- 26:13Speaker 2: They're presented as module.
- 26:14Speaker 1: Pieces, and Chapter ten, the last part is about putting
- 26:18Speaker 1: it all together. How do these modules actually interact in
- 26:21Speaker 1: a real game.
- 26:22Speaker 2: Well, the key takeaway from that chapter blueprint is showing
- 26:25Speaker 2: that these systems don't live in isolation. A functional game
- 26:27Speaker 2: level isn't just a pretty scene. It's where these systems
- 26:30Speaker 2: collide and interact.
- 26:32Speaker 1: So designing a main menu scene would integrate the UI blueprint,
- 26:36Speaker 1: the audio blueprint for menu music sounds, and the configuration
- 26:40Speaker 1: blueprint for the option screen exactly, and.
- 26:43Speaker 2: A playable level uses the AI blueprints for enemies, the
- 26:46Speaker 2: stats and scoring blueprints for tracking progress, the item and
- 26:50Speaker 2: inventory blueprints for pickups, and the saveload blueprint for persistence.
- 26:54Speaker 1: Player actions become the glue. Right, Like shooting an enemy
- 26:57Speaker 1: isn't just a visual.
- 26:58Speaker 2: Effect, right, the blue blue print shows how that single
- 27:01Speaker 2: action shooting might trigger SFX using the audio blueprint, possibly
- 27:06Speaker 2: alert nearby enemies, or change the target's AI state using
- 27:10Speaker 2: the AI blueprint, and maybe increment the player's kill stat
- 27:13Speaker 2: using the scoring.
- 27:14Speaker 1: Blueprint and pausing the game might bring up the settings
- 27:17Speaker 1: guy config blueprint. Picking up a health kit uses the
- 27:21Speaker 1: item class blueprint and tells the inventory system blueprint to update.
- 27:25Speaker 2: It's all about these systems sending messages or calling functions
- 27:28Speaker 2: on each other, updating shared variables, and reacting to events
- 27:31Speaker 2: triggered by the player or the game world itself.
- 27:34Speaker 1: So the process of building the game involves adding the
- 27:36Speaker 1: sound managers, implementing the GUI for stats and options, adding
- 27:39Speaker 1: the saveload scripts, basically wiring these blueprints together yes.
- 27:44Speaker 2: And linking game logic like win conditions. The blueprint mentions
- 27:49Speaker 2: checking if enemies equals zero, That condition links back to
- 27:53Speaker 2: the AI and STAT systems. Killing an enemy AI interaction
- 27:56Speaker 2: updates the player's kill stat and decreases the enemy count
- 28:00Speaker 2: that the wind condition is monitoring.
- 28:01Speaker 1: It really emphasizes that these are well blueprints building blocks.
- 28:05Speaker 1: You learn how to make a working inventory, a working AI,
- 28:08Speaker 1: a working save system, and then you combine them, customize them,
- 28:11Speaker 1: expand on them to build something bigger.
- 28:14Speaker 2: It's about understanding the components so you can assemble and
- 28:16Speaker 2: adapt them creatively.
- 28:18Speaker 1: So wrapping up this deep dive into the Unity game
- 28:21Speaker 1: development blueprints source material, we've really taken a shortcut through
- 28:25Speaker 1: a whole range of corese scripting concepts from the absolute
- 28:28Speaker 1: fundamentals like controls and UI.
- 28:30Speaker 2: Through managing items in inventory, bringing the world alive with AI,
- 28:34Speaker 2: tracking player progress with stats and achievements, making sure that
- 28:37Speaker 2: progress sticks with saving and loading.
- 28:39Speaker 1: And adding that essential polish with audio integration and configurable
- 28:43Speaker 1: game settings.
- 28:44Speaker 2: Understanding these modular blueprints, even just conceptually, gives you a
- 28:48Speaker 2: really powerful starting point, a clear path for building functional
- 28:52Speaker 2: features quickly and ultimately putting together entire game experiences.
- 28:56Speaker 1: And for you, the listener, as you think about these
- 28:58Speaker 1: different blueprints may be consider this every single technical piece
- 29:03Speaker 1: we talked about, that variable holding a key assignment, the
- 29:06Speaker 1: line of code that counts a kill, the function that
- 29:09Speaker 1: saves data, the setting for shadow quality. It isn't just
- 29:13Speaker 1: technical minutia.
- 29:15Speaker 2: Yeah, the specific way these systems are designed and implemented,
- 29:18Speaker 2: the choices made in the blueprint, they directly shape how
- 29:21Speaker 2: the player actually feels playing the game. Does it feel responsive?
- 29:25Speaker 2: Is it fair? Is it engaging?
- 29:28Speaker 1: That technical implementation directly translates into the player's moment to
- 29:32Speaker 1: moment experience, their interaction, even the kind of emotional connection
- 29:35Speaker 1: they might form with the world you've built using these blueprints.
- 29:39Speaker 2: The code isn't just instructions for the computer, it's fundamentally
- 29:43Speaker 2: shaping the human experience on the other side of.
- 29:45Speaker 1: The screen, A fascinating connection to keep in mind. Thanks
- 29:47Speaker 1: for joining us for this deep dive.
- 29:49Speaker 2: Until next time.