Trending
Opinion: How will Project 2025 impact game developers?
The Heritage Foundation's manifesto for the possible next administration could do great harm to many, including large portions of the game development community.
Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs or learn how to Submit Your Own Blog Post
How to efficiently and easily detect a surface for audio, particles, or gameplay.
One of the most common things you do in video games is detecting a surface of an object. You do it when you want to play a footstep sound and particle, when you want to show a bullet decal on a wall or when you want to know if you have hit a soft body or a hard metal.
Since it’s so commonly used it should be written in a way that is easy and efficient to utilize. For our game The Lightbringer we have created a simple yet effective system from a few parts.
First we have a surface type:
This is basically just data. We then create scriptables for each surface type.
Then we have a Surface script that can be attached to any object on the scene:
And the most important part, where all the magic happens, the surface manager:
Here we keep a lookup of all the surface objects. Upon starting the game, every surface registers in this lookup.
When we want to check what surface type any object has we can use GetSurfaceType method. A simple example:
And that’s all there is to it. It’s pretty straightforward, nothing revolutionary, but then again I saw so many projects which lacked a system like this, that I thought I’d share.
If you want to check out our work: https://linktr.ee/rock_square_thunder
Janusz
Read more about:
Featured BlogsYou May Also Like