The Shredder is another weapon inspired by many wasted hours playing Turok 2 on the N64 back in the day. In Turok it’s a weapon that fires a laser that bounces off anything it hits, you can it in action here.
I knew that to get this mechanic to work I was going to need a method of collision detection that was more robust than the current system I’m using due to the speed the shredder’s ‘beam’ would be travelling. My current system relies on objects actually colliding at the point at which the collision checking is done, this is fine for the most part but will fail when very fast objects more ‘through’ smaller objects (the so-called ‘bullet through paper’ syndrome).
So I started looking at how to implement a basic raycasting algorithm to check for collisions instead. I am not great at Math(s) so was slightly dreading this, but thankfully I found a YouTube video that was able to explain to explain the calculations involved in simple raycasting here. There’s some very clear code linked to from that same video.
I was able to implement a decent enough raycasting algorithm fairly painlessly, so the next step was to work on the visuals. I didn’t really like a plain ‘laser beam’ type effect as is used in Turok, so began working with smaller particles instead. I felt a weapon called the ‘shredder’ should look at least vaguely like it’s tearing things to pieces!
After several hours of tweaking particle parameters (a process I am now getting a bit tired of) I managed to settle on an effect I was pretty happy with and seemed to fit with the name ‘shredder’. There’s two sets of particles here, one which stays aligned with the ‘beam’ and one which drifts away from it. Also particles are added when the ‘beam’ reflects off a surface.
I uploaded this to Twitter thinking I was done, but after coming back to it felt the trail of the ‘beam’ was too dispersed. It needed some kind of central ‘pulse’ or something. I also had some feedback, again via Twitter, to this effect so I wrote a simple shader that allowed me to taper a beam out to a point and used this. I also focussed the distribution of the particles a bit more.
Now I think I am done!
Dev Time: 2 days
Total Dev Time: approx 138.5 days

First Steps Testing The Raycasting Algorithm

Adding Reflection And Testing A rough ‘Laser Beam’ Effect

The Point At Which I Thought I Was Done

The Final Weapon In Action
One Trackback
[…] meant I needed to use raycasting for the collisions. Fortunately I could reuse code from the ‘shredder‘ weapon but still, this was non-trivial due to my lack of foresight in the way the original […]