I built the murder slingshot

Avatar image for bushpusherr
bushpusherr

1080

Forum Posts

2

Wiki Points

0

Followers

Reviews: 0

User Lists: 6

Edited By bushpusherr

(*Full disclosure: this blog will discuss elements that I built for the purposes of my twitch stream. I don't want this to come off as though I'm sneakily trying to self promote because I really just want to geek out for a bit about what I built, so let's get this out of the way up front. Yes, of course it's cool if people check my stuff out if they feel it speaks to their interests, but no, that isn't the focus of this blog. Let's get into it!*)

For whatever reason, this Bombcast segment has lingered in back of my mind ever since I heard it in 2012.

In the last few months I finally began putting real work into an idea I had to combine my software development experience & education with my interests in video editing & production to develop a custom application for the purposes of making a fun stream to fool around with with my friends. At perhaps the exact moment I decided that I wanted to do something silly to visually represent people getting banned from my channel, this Bombcast clip sprinted to the front my mind and I didn't even consider doing anything else. I wanted to launch my enemies into the sun with a slingshot.

I immediately began experimenting (in Unity, where I developed all of this) with slingshot physics in a test environment where I launched a low-poly avatar into a mountain.

No Caption Provided
No Caption Provided
No Caption Provided

I eventually settled on a solution where an invisible anchor point in space (represented here by the brown cube) would be connected to the center of the launch chassis (the white "box" that our avatar resets in) with a single spring joint. The function of a spring joint is to continuously apply a specific amount of force to attempt to return the connected body back to it's original distance relative to the anchor it's connected to. So, in this case, our launch chassis will fight against gravity to stay about a half-meter below our invisible anchor point. If our spring force is stronger than gravity, the chassis will simply hang in the air (perhaps swaying slightly due to the position and mass of the avatar resting on the chassis).

Given this information, you have perhaps already deduced how the actual slingshot launch works. By disabling the physical components of these objects (disabling the gravitational pull, stopping the spring from applying it's force, etc), I can freely re-position ("pull back") the launch chassis towards the mounting point and leave it there until I'm ready to fire.

No Caption Provided

By simply re-enabling the physical components, the spring will intuitively pull the chassis towards the anchor point. The force applied will push the chassis through the anchor point and the momentum will carry it beyond. Once that occurs, the spring force will eventually counteract that forward momentum and begin pulling the chassis back again from the other direction. Up to this point, gravity and the upward force on the chassis were the only things keeping our avatar connected to our chassis as it thrust towards the anchor point. But without a spring to pull it back, our avatar is now free to keep it's forward momentum as the chassis below it reverses course.

You may have noticed the large, hollow, green outline of a cube beneath our chassis. This is a collision volume that only interacts with our avatar, and its size is such that it allows us to use higher spring forces to pull the chassis and have the avatar maintain it's position on top of it without clipping through the thin chassis floor. There is a lot more I could say about the update rates of physics calculations vs transform positions, the nature of rigid bodies, etc, to explain why this large collision volume is a solution here, but that's a bit more technical than I'd like to get.

Now that I had that part solved to my satisfaction, I started thinking about the aesthetics of the sun. Of course, a pretty specific image quickly came to mind. I'm guessing @vinny would have probably thought of the same scene. Can you name a more iconic star in video games than the one seen from the view of the Illusive Man's room in Mass Effect 2 & 3?

No Caption Provided

I'll show off where this inspiration eventually took me before getting into the details:

It animates as well, which you'll see a bit further down the page.
It animates as well, which you'll see a bit further down the page.

To get the simpler stuff out of the way up front: the background is a straight forward skybox, and the floor is the top of a large cylinder (default Unity model) that has a shaded mirror reflection script & material applied with a basic tiled normal map to achieve the grooves in the floor. The bright lighting on the floor isn't actually coming from the sun itself, it's simply a separate directional light shining onto it.

The real fun part here is the star, of course. I just used the Unity standard sphere model as the mesh, and everything else is done in a shader/material that I wrote. I'm fortunate enough to have a CS masters focusing on real-time graphics, so this part was especially exciting for me to work on. Here is a side by side difference of the final sun vs. standard sphere to show exactly how much the shader is changing:

No Caption Provided

The primary tool at play here is the use of something called Perlin noise, which is a mathematical function developed by Ken Perlin that generates collections of random values that smoothly vary between 0 (black) and 1 (white). Multiple sets of these values can be generated with differing frequencies, wavelengths, and other modifications and then combined to create some really intricate noise. You can also modify one or more of these parameters by time to animate this noise. Here is what the sun would look like if I strictly output the value of my Perlin noise implementation and didn't colorize it:

No Caption Provided

This material is using 12 "layers" of random values, each with slightly different parameters, that combine to form this smoky appearance. You can adjust how much impact each of these layers has on the final product, as well. Here is what this would look like with using 1, 2, and 4 layers respectively:

No Caption Provided

I then took the output of this Perlin function and put it through a variety of power functions (squared/cubed/etc) with some other clamping & fine adjustments involved, and then multiplied those differing results by various colors. There is a *bit* more going on there, but again, probably too technical. If that colorization were applied to the previous image, we'd have this:

No Caption Provided

The last major component to this (which will really show through primarily in the animated version) is that I am also slightly displacing the vertices of the mesh by this noise value as well. Basically, I'm moving the vertices of the mesh a little bit closer or further away from the object's center based on the [0,1] output from the noise function. This effectively just makes the sphere bumpy/jagged. To show an extreme example to illustrate the concept, this is what a pretty high displacement intensity would look like with a single layer of noise:

No Caption Provided

Another important characteristic of this displacement is that, even with our 12 layers of noise that I ended up with, we are still only displacing as many vertices as are actually there. Here is the same displacement but with the updated noise values:

The bumps look slightly different because the time changed between screenshots, and the noise we are getting our displacement value from now has more details. Time is integrated for animation purposes.
The bumps look slightly different because the time changed between screenshots, and the noise we are getting our displacement value from now has more details. Time is integrated for animation purposes.

The default Unity sphere is a pretty simple mesh without many vertices to work with. In order to get less of a jagged displacement, we can let the graphics card generate more vertices for us that get placed in between the existing ones in a process called tessellation. Here is what the wire frame of our properly displaced and tessellated sphere looks like compared to the starting model:

Now, the density of our model's vertices can appropriately utilize the fine details of our noise function to create much smoother displacement.
Now, the density of our model's vertices can appropriately utilize the fine details of our noise function to create much smoother displacement.

And with that, I think it is finally time to show you what this thing actually looks like in action. Unfortunately (but actually, fortunately?) I didn't have anyone behaving badly enough to warrant a ban during my first weekend with the stream for the Blackout beta, so I had to do some symbolic launches of people who were being jerks from within the game itself (people telling others to kill themselves, shouting racist/homophobic garbage, etc). My process was setup to integrate the name of the person being banned, but defaults to "Unknown" if that ban queue is empty. I already have improvements planned to let me add these names manually for such occasions, but I was too excited to talk about this to wait and get more video haha.

Wherever the power meter is stopped, as if this shit were Mario Golf, determines the force of the spring that pulls the launch chassis. I made sure to adjust it so that low-power shots were still pretty fun, lol. Given that I showed how the slingshot was implemented you probably already guessed, but the slingshot wires and posts they are connected to are all purely cosmetic.

Political opponents beware, the Gerstmann 2020 platform is ready for action.

Avatar image for bed
bed

12934

Forum Posts

14417

Wiki Points

0

Followers

Reviews: 1

User Lists: 24

Holy moly, this is fantastic! Thank you for sharing this (and for making it easy for dummies like me to understand)

Avatar image for redhotchilimist
Redhotchilimist

3019

Forum Posts

14

Wiki Points

0

Followers

Reviews: 0

User Lists: 2

Hahah, that gave me a good laugh. That's a great use of the concept, and it ended up looking real good too.

Avatar image for emprpngn
emprpngn

841

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 4

That's one of my favorite Bombcast moments as well. I really enjoyed the write-up, and the end result is super cool!

Avatar image for wadtomaton
wadtomaton

609

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 1

Hahah that's great. The Wilhelm Scream is a nice touch.

Avatar image for the_nubster
The_Nubster

5058

Forum Posts

21

Wiki Points

0

Followers

Reviews: 3

User Lists: 1

I've only read a bit of your post and I'll go back and finish it, but I also wanted to say that the murder slingshot segment has stuck in my mind ever since I heard it. I think about it, like, once per week. It's insane.

Avatar image for securityguruguy
SecurityGuruGuy

179

Forum Posts

251

Wiki Points

0

Followers

Reviews: 0

User Lists: 1

This is fantastic.

Avatar image for chilibean_3
chilibean_3

2406

Forum Posts

324

Wiki Points

0

Followers

Reviews: 0

User Lists: 5

It's a classic Bombcast segment and a fantastic accomplishment.

Avatar image for humanity
Humanity

21858

Forum Posts

5738

Wiki Points

0

Followers

Reviews: 40

User Lists: 16

Avatar image for sergiy
Sergiy

73

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

Oh my god that's fantastic!

Thanks for the write-up and for sharing.

Suggestions if you want them:

- longer flight to the sun (suspense!)

- have the username float over the model the whole time

Might check out your streams for my murder slingshot fix :)

Avatar image for bushpusherr
bushpusherr

1080

Forum Posts

2

Wiki Points

0

Followers

Reviews: 0

User Lists: 6

Thank you all so much for all of the kind words!

@sergiy said:

Suggestions if you want them:

- longer flight to the sun (suspense!)

- have the username float over the model the whole time

Thanks for the suggestions! I think I probably agree with the longer flight times. I've thought about pushing the sun even farther away and just making it larger to compensate, but I'll need to spend some time tuning the power meter to make sure my spring forces operate smoothly over the full spectrum. Right now there are basically 3 scenarios: Too weak of a force just dumps them onto the platform (which I find hilarious), a middling force clears the platform but just dumps them off into the void of space in between, or a strong enough force to get them to the sun with varying trajectories (currently a 75% power shot gives them a really satisfying high arc towards the top of the sun). The middling force is obviously the least satisfying, and that scenario would increase in frequency with a larger distance between the platform and the star, but I suppose there are a few ways I could solve that. I could experiment with turning gravity off (it doesn't really make sense in this outer space scenario anyway lol) and seeing how each power level performs, or I could experiment with sort of Lakitu-like system where something rescues them from the deep for another shot.

Regarding the username, I'll probably at least leave the names getting crushed into the platform as a thing, because I can actually reload the slingshot with the next user without backing out back to gameplay to reset the whole scene. As I reload more and more, all the letters from the previous names just keep piling up on the platform as a sort of username graveyard haha. *However*, I already have plans (and partial implementations) in place for making the avatars more user-specific, which would at least partially speak to your suggestion :). I have a stream currency (bushbucks, i know i know sorry sorry sorry) that viewers accrue as they watch/interact with chat, and I'm going to have an in-stream shop where they can buy hats/shirts/etc to put on their little avatar so that when they show up on stream (I have other scenes besides this where they would show up in less dire circumstances, lol) their little avatar would be personalized for them with whatever they've purchased/earned and equipped.

Regardless, thank you so much for the feedback! I've been locked in working on this whole project for a few months now and have only shared bits and pieces with close friends, it's so nice to finally get it in front of people and hear their thoughts!

Avatar image for zaccheus
zaccheus

2140

Forum Posts

36

Wiki Points

0

Followers

Reviews: 0

User Lists: 5

Pretty damn amazing.

Avatar image for rcath
rcath

677

Forum Posts

82

Wiki Points

0

Followers

Reviews: 0

User Lists: 2

amazing

Avatar image for sergiy
Sergiy

73

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@bushpusherr: Its an awesome project you got going, and clearly a lot of thought and effort went into it, and now i can see even more is going into it xD

This way the middle throw would send them slowly drifting into the sun, could even play some classical music as they float to their doom!... But would mess up the other physics.. Still could be a fun consoderation!

The Lakitu would be funny, especially if it steals some of the stream currency from them, Mario Kart style.

Looking forward to see how this evolves!

Avatar image for bushpusherr
bushpusherr

1080

Forum Posts

2

Wiki Points

0

Followers

Reviews: 0

User Lists: 6

@sergiy: So, even without the Lakitu-style adversary, I'm actually *already* reclaiming their currency...all of it (at least for those who were banned as actual viewers, not "symbolic" bans) haha. Everytime someone gets banned, all of their bushbucks get thrown into a general pot that I'm calling the "ban bounty." I'll occasionally have various opportunities for someone in chat to win/earn/claim that bounty through some manner of challenge.

Avatar image for selbie
selbie

2602

Forum Posts

6468

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

Great work on this. Two of my favourite things - Mass Effect and Murder Slingshots.

Avatar image for manburger
Manburger

541

Forum Posts

28

Wiki Points

0

Followers

Reviews: 0

User Lists: 7

#17 Manburger  Online

Haha, holy shit! Terrific work! :D