NokiMo
factorysettings
factorysettings

patreon


TD Gamedev progress: collision system

Hi friends, pretty excited about this update! We're currently finishing a descent collision system within our search whether it'll be possible to create an environment for game development inside Touchdesigner. And not to be to poshy about it, it's getting pretty watertight!

This was a headscratcher to be honest. I just went on and off with shall I use the colorbuffers or not. I've posted earlier some insights on the collision system using a depth camera, and a normal to camera pass. It sort of worked ok-ish, but it never really got to that point I would consider it 'watertight' and suitable for further development.

Soooo just dusting off your math then. Well it was worth it. I just started with generating a circle of spheres around the character and let that one follow the positions and rotations. That was quite easy, just basic instancing stuff. The convenient thing was that I now had the ability to color the individual spheres. I wanted to get to the point where the sphere would turn black when it crosses a collision border. 

I was desperately looking for some vector approach, since that was already fresh in my mind but then I thought, well I have the height map already loaded in for controlling the Y position of the character, why not use that for collisions as well? White is ground floor, black a wall right? Sampling from the heightmap felt like a bottleneck at first, but it actually works quite well. The drawn collision spheres are just basic sine and cosine formulas, feed those into a TopToChop and you have your colordata!

From there on you just have to get the 'first' and 'last' black sphere, there comes the analyzeCHOP in handy. You now basically have a straight line intersecting a circle at two points. This line forms an angle with the direction the character is pointing at. Why I first wanted to look if I could fix it with vector math, the direction the character is pointing opposites the wall is just a simple dot product calculation. I certainly don't want to trivialize this process. It can be quite daunting at first, so please don't feel stupid if this all doesn't make sense. But an understanding of basic trigonometry would be helpful, because that's what this all is. Look for the angle the character is making confronting a wall. Then you can calculate how the character needs to bend off, in what direction and at what speed. 

So if the character would confront a wall at a straight angle, the dot product would be '0', from a trigonometry perspective you also could say '0', or '90', it just depends on what your starting angle would be.

Currently in polishing stage, have to finalize the sideway collisions and how the collision system will not interfere with the height calculation. So anytime soon for an updated .toe file with a decent collision system! I also cleaned up quite some networks, especially in the keyboard input region, lookupCHOP is currently my friend. Also can't wait to update the level itself, trees and flowers would be nice.

Still having difficulties with perform mode in combination with an extended desktop over two screens. The mouse data still freaks out, have to unplug one of the screens in order to make it work. Not the end of the world, but quite annoying that I havn't worked this out yet. If anyone has any ideas, contact me!

As always, you're making this possible! Thanks for the support!

TD Gamedev progress: collision system

Related Creators