Events, actions, enable, disable, lots of stuff going on here. How can we simplify this a little and get to basics. Let’s start by creating a capsule and do a simple movement system. I’m going to create a player capsule and add simple controls the old way.
Structs are almost exactly the same except they don’t do inheritance. So we can’t create sub-categories inside a struct like we could a class.
Structs are a value type — value types are stored on the stack
int age = 25; — this is a value type, the value is stored directly in this line.
bool type = true; this is a value type
string name = “name” ;— this is a value type
You can change the original value of this.
Class are a reference type — reference types are stored on the heap
string myName = “Jonathan”; — this is stored into memory on a certain address on RAM.
You cannot change the original value type — only create a copy
How can I get a script to override a class with a function? Let’s start with a main script of pets.
Now let’s create a Duck script. We want to change the speak from “speak” to “quack quack”. How do we do this? We change the function to virtual!
Let’s create a banking system. First, let’s define the bank with the proper variables that all banks share.
We want to do 3 functions — check balance, withdrawl, and deposits. Next, let’s create a bank and define it’s role.