Okay, so today I wanted to mess around with something called “Norris Collision.” I’d heard about it, seen some stuff online, but never actually tried it myself. Basically, it’s about detecting when things bump into each other in a game or simulation, a concept I’m interested in.
First, I needed a testing ground. I just threw together a super basic scene, nothing fancy. I’m just use my old working tools. Imagine a flat plane acting like the floor, and then a couple of cubes I could move around. The important thing was to make sure at least one of the objects had what’s called a “rigid body” component – that’s what tells the engine that this thing should react to physics, like gravity and collisions.
I attached a simple script to one of the cubes. This script was super bare-bones, just letting me use the arrow keys to nudge the cube around. Again, nothing complex, I just wanted to control one object’s movement. I’m use ‘wasd’ to do so.
Now, here’s where the “Norris Collision” part comes in (though, honestly, it’s just regular collision detection – the “Norris” part is more of a fun, made-up name for this particular experiment). I added another script, this time focused on detecting collisions.
This new script used a built-in function. This function is like a little alarm that goes off whenever the object this script is attached to collides with anything. Inside that function, I put a simple debug message. It’s like writing a note to myself, saying “Hey! Something just crashed into me!”.
- Create a new plane and two cubes.
- Add a “RigidBody” component to one of the cubes.
- Create a first script for movement (e.g., using arrow keys).
- Create a second script for collision detection.
- Use the special function to detect the collision.
- Put a debug message inside that function.
The Moment of Truth (or Impact)
I hit play, used my arrow keys to move the cube around, and… bam! As soon as it bumped into the other cube, my debug message popped up in the console. Success! It was such a small thing, but seeing that message appear right when the collision happened was incredibly satisfying. I moved my cube around, crashing it into the other cube from different angles, and the message kept appearing. It worked flawlessly!
I then wanted to see what would happen if I made the other cube the one with the RigidBody and collision detection. So, I switched things around, removing the RigidBody from the first cube and adding it to the second. I also moved the collision detection script to the second cube. I ran the simulation again, and… it still worked perfectly! The message popped up whenever the first cube (controlled by me) bumped into the second one.
It’s a small test,but this is the foundation for so many things in game. It’s super simple, but it’s that fundamental building block that you can then build upon. Now i can move to the next stage, the more complex stuff.