I’m trying to make a collision detection system where each game object reacts differently to other game objects by checking what type the game object it collides with is.
I keep getting:
‘Rat’ is a ‘type’ but is used like a ‘variable’.
This the code I use to detect what kind of objects collide and decide what to do when an object collides with another of a certain type:
switch (other.Type) {
case Rat:
float tooClose = (Radius * 2) - distance.Length();
distance.Normalize();
PositionAfterCollisions += distance * tooClose * 0.5f;
VelocityAfterCollisions = -Velocity;
}
'other' is here a reference to a game object in the collision list.
And this is from the top of the class/GameObjectI’m trying to identify + the class it inherits from:
public enum ObjectType
{
Default,
Player,
Rat,
Cheese,
Trap,
Home
}
public ObjectType Type = ObjectType.Rat;
in C#, enums are always qualified by name.
You’d need