SCREEN SHAKE WITH NO CODE - EASY UNITY TUTORIAL

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back to black thorn prod I'm Noah screen shake will without a doubt add an extra layer of life to your creation it gives the feeling that the player's actions have a real impact on the world it will juice up explosions render hits more satisfying and yeah just make your game especially an action-oriented one more fun and interesting to play and so in today's video I'll give you a look at how to add screen shape to your own game without codes but by simply using the animation and animator windows inside of unity Chernov we will have to write true lines of codes to get our screen shake animation playing at the right time where that doesn't really count so so I have this little game setup with a player that can shoot squishy monsters coming from the right these monsters explode when shots but what this really misses is some screen shake so let me grab my main camera head over to the animation window and hit creates new animation I'll call this first one idle and with the record mode set on I'll make sure my camera is at its default position this way when we make our second animation of the screen shake one will be able to then smoothly transition back to this default position and so talking about a shake animation let's make one now of course the amount of shape you want depends on your game I feel as if just a tiny bit is enough for regular actions like shooting and killing enemies too much I'm your player may feel nauseous so with the record mode set on once again I'll move my camera tiny bit to the left so after one or two milliseconds and then two milliseconds after that recenter it's at six milliseconds I'll get my camera shifting ever so slightly to the right and then recenter it and there we go our shake animation is completes now again you can definitely go ahead and play around with this perhaps getting the camera to shake for a while longer or make the shake more prominence by shifting the camera more to the left right up or down so really have fun testable you feel works best for your game and once you're satisfied head over to the animator window and create a new trigger condition I'll just call shape then make a transition going from idle to that shake animation grabbing the transition arrow add the shake condition uncheck exit time and zero transition duration lastly I'll make a second transition this one going from shake to idle here I'll set exit time equal to 1 and transition duration equal to zero I'll also uncheck the loop box for the shake animation for a lots more on animation transitions check out this video on the topic I'll now create a new C sharp script called shake and drag and drop that onto an empty game object inside it I'll create a public variable of type animator called cam anima and then make a public function called cam shape insider I'll simply play my shake animation all I now need to do is call this function from some other scripts to get my screen shaking for example let's say I wanted the screen to shake whenever a project tile destroys an enemy I would simply need to head into my project I'll scripts which were now handles the bullets movement and enemy destruction and create a private variable of type of shape called shake in my start function I'll then say shape equal to the game object with a tag called screen shake and more precisely the shake component attached to that game object without further ado I'll head back into unity and create a new tag called screen shape adding it to my empty game object with a shake script attached to it as well has drag-and-drop the camera inside the camp anam empty slots now that that's done I can simply type shape dot cam shape inside of my ontriggerenter 2d function which I remind you is called whenever the projectile collides with something so I'll now hit play to test this out and whenever my project I'll collides with an enemy the screen will shake awesome one thing to note however is that if had the camera following the player around the scene and we played this shake animation then we would get this annoying situation where the camera would snap to its shake animation positions to avoid this from happening make an empty game object called can follow play sir right over your camera and then parent your camera to that newly made object once that's done you'll simply need to add your camera fall scripts to that empty game objects and things will work smoothly lastly you may want some randomness in your camera screen shape all you would need to do is create several shake animations make several trigger conditions inside of the animator and use one for each shake animation and then inside the shake scripts that create an int variable called Rand and set that equal to a random number between 0 and the amount of shake animations you have and then you can make a series of if statements checking what Rand is equal to and play a different shake animation thanks to your various trigger conditions depending on rands value and now we have some random shake emotions which makes the game feel all the more awesome and satisfying to explore ok I hope you enjoyed the video and were able to follow along hitting the like and subscribe buttons would be so appreciated and encouraging also consider supporting Levi's patreon like these top supporters time is a precious resource much of it would have to be spent on work and creations other than the channel so if you find this regular content helpful I want to keep up become a patreon help the community and get some cool humble rewards in exchange ok thanks so much for watching stay tunes Cheers [Applause] [Music] [Applause] [Music] [Applause] [Music]
Info
Channel: Blackthornprod
Views: 110,914
Rating: undefined out of 5
Keywords: blackthornprod, noa calice, shake, game dev, game feel, juice, characters, 2D, camera, camera shake, easy, quick, satisfying, game juice, vlambeer, nuclear thrones, CAMERA SHAKE WITH NO CODE - EASY UNITY TUTORIAL, camera shake in Unity, C#, c#, progarmming, coding, indie game dev, patreon, nuclear throne, screen shake
Id: N24MhfeoUpE
Channel Id: undefined
Length: 6min 27sec (387 seconds)
Published: Wed May 16 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.