No video

How to do Camera Shake with Cinemachine!

  Рет қаралды 87,594

Code Monkey

Code Monkey

Күн бұрын

✅ Get the Project files and Utilities at unitycodemonke...
Let's learn how to apply Camera Shake when using Cinemachine!
👇
🌍 Get Code Monkey on Steam!
👍 Interactive Tutorials, Complete Games and More!
✅ Add to your Wishlist! 👉 store.steampow...
Applying Camera Shake to Cinemachine is actually very easy.
Select you Cinemachine Virtual Camera and at the bottom you will see the Noise tab.
You can select a Multi-Channel Perlin and then select 6D Shake.
This will apply noise to the camera in all 6 directions which will equal Camera Shake
By playing around with the Frequency and Amplitude you can get exactly the type of Shake you want.
Then make a Script to control it, use cinemachineVirtualCamera.GetCinemachineComponent-CinemachineBasicMultiChannelPerlin-(); to get the Cinemachine Component and then modify m_AmplitudeGain;
Easily Control Cameras with Cinemachine in Unity
• Easily Control Cameras...
If you have any questions post them in the comments and I'll do my best to answer them.
🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
See you next time!
📍 Support on Patreon / unitycodemonkey
🤖 Join the Community Discord / discord
📦 Grab the Game Bundle at unitycodemonke...
📝 Get the Code Monkey Utilities at unitycodemonke...
#unitytutorial #unity3d #unity2d
--------------------------------------------------------------------
Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.
I've been developing games for several years with 7 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
You can see my games at www.endlessloopstudios.com
--------------------------------------------------------------------
- Website: unitycodemonke...
- Twitter: / unitycodemonkey
- Facebook: / unitycodemonkey

Пікірлер: 269
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Cinemachine Camera Shake! I couldn't find a simple tutorial on it so I'm hoping this will help someone! 🌐 Have you found the videos Helpful and Valuable? ❤️ Support on Patreon www.patreon.com/unitycodemonkey or get the Game Bundle unitycodemonkey.com/gamebundle.php
@aarondelgado3421
@aarondelgado3421 4 жыл бұрын
It doesn't make sense to love your own comment.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Why not? I use the hearts to highlight comments, naturally I want to highlight my comment with helpful links.
@tate_talk574
@tate_talk574 4 жыл бұрын
Codemoney I was on your discord sever but I seen some stuff and left but I'm thinking of coming back your a good coder and it's easy to understand and I like it when you fast-forward to get the boring part out of the vid just watching you type and the greatest part is when I get to see the code
@hemantbisht7079
@hemantbisht7079 3 жыл бұрын
Hey code monkey can u please help me out. I did same steps you did but i am getting an error "cinemachinevirtualcamera does not contain a definition for basicmultichannelperlin". I have alredy included using cinemachine. Please help me out i am not gettin it I am using cinemachine 2d camera.
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
@@hemantbisht7079 Sound like you didnt add the noise extension
@jonordona9733
@jonordona9733 4 жыл бұрын
If anyone is trying to apply this to 3D and is using a FreeLook Camera, just be aware that the Free Look Camera is actually just three Virtual Cameras, each one on the bottom, mid, and top rig. To access them I've had to use a for loop and using the GetRig method, which accepts an integer (Just use 0,1,2), then, you can access the Perlin component of each rig and apply what's explained in the tutorial. By the way, these tutorials are amazing! Straight to the point, no wasting the viewers' time. Thanks!
@everythingonit3159
@everythingonit3159 2 жыл бұрын
Thanks for the tip, it worked for me.
@ignatiuswallmeyer9838
@ignatiuswallmeyer9838 2 жыл бұрын
@@everythingonit3159 Yeah, doing mine now:)
@AdamMarshall-fw6no
@AdamMarshall-fw6no Жыл бұрын
@@ignatiuswallmeyer9838 yea i was wondering how to work with a free look thank you
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
🌍 Code Monkey on Steam! 👍 Interactive Tutorials, Complete Games and More! ✅ Add to your Wishlist! 👉 store.steampowered.com/app/1294220/
@erosjagatpulagana6403
@erosjagatpulagana6403 4 жыл бұрын
i'm aware that there are still few Cinemachine tutorial out there, especially on youtube, so thank you so much for adding this! Wish i could have this long ago, but it's better than nothing, and still helpful to help my current project
@horrorshelter
@horrorshelter 4 жыл бұрын
I just realized i don't know anything about unity
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
How so? If you are a complete beginner then don't start with a camera shake effect, start with the absolute basics.
@dragovscar
@dragovscar Жыл бұрын
First time?
@jeongbalsancat
@jeongbalsancat 4 жыл бұрын
I've never even thought about using Cinemachine.. this will make my side scrolling game look sooo polished. thanks so much!
@algs5483
@algs5483 4 жыл бұрын
Geez, thank you a ton. I'm participating a game jam and needed a camera shake, but I was using Cinemachine and couldnt find a way to shake my camera with Cinemachine, but then this video appeard. Thank you!
@ChimpanzeeUltra
@ChimpanzeeUltra 4 жыл бұрын
What the... I searched for this video in the previous month when I was trying to make a harder project than I make now! Thanks! When I will end with the current project I'll be needing of this video :)
@s_abhinav
@s_abhinav 3 жыл бұрын
I love your tutorials but can you please give detailed explanation in coding, as I feel you are little bit faster.🙏🏻 This is just a suggestion.
@357molotov
@357molotov 2 жыл бұрын
For anyone who had the same issue as I did; the camera wouldn't stop shaking once it started. So had to change: Mathf.Lerp(startingIntensity, 0f, shakeTimer / shakeTimerTotal); to this: Mathf.Lerp(startingIntensity, 0f, 1 - shakeTimer / shakeTimerTotal); Excellent tutorial though, thank you!
@noahcarlisle4470
@noahcarlisle4470 2 жыл бұрын
Good to know. Thx
@pierredalaya444
@pierredalaya444 3 жыл бұрын
You can also use the cinemachine Impulse component instead of writing code
@from10sto0z6
@from10sto0z6 4 жыл бұрын
Thank you so much! Im now on the finishing touches of my first game jam and you have saved my game, Keep rocking the tuts!
@gamedevjedi8212
@gamedevjedi8212 4 жыл бұрын
Sweet! I love that effect in certain situations. When, I'm playing haha ...I'm brand new to game development, so probably won't use this for a bit, but still super fun to learn all this new stuff! Thank you buddy!
@ScilexGuitar
@ScilexGuitar 3 жыл бұрын
How is it going, after 5 months ?
@samyam
@samyam 4 жыл бұрын
Great video, thanks!
@behnamrasooli8801
@behnamrasooli8801 4 жыл бұрын
Funny to see that the 'm_AmplitudeGain' field in the 'CinemachineBasicMultiChannelPerlin' class is public! This shows that a team member in Unity doesn't quite understand the naming convention. 'm_' means it's a member variable and it should be private.
@BioToxin
@BioToxin 4 жыл бұрын
Dude I've been wondering about this as a final touch for a while thanks
@skymakr8727
@skymakr8727 3 жыл бұрын
i have been searched this for ages
@VarelaMar
@VarelaMar 4 жыл бұрын
Wow, amazing! Please make a video about code reusability and how to organize your utils like you do! Thank you, for the great tutorials!
@michaelzhao5873
@michaelzhao5873 4 жыл бұрын
How do you read my mind? My next devlog is gonna require a camera controller rewrite using Cinemachine which I'll use this tutorial for... At this rate, I need to put "Made with Code Monkey's help" in the title screen of my game... 😂
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Hehe awesome! I'm glad the videos have helped you!
@blackblocky3866
@blackblocky3866 2 жыл бұрын
thanks for the great tutorial!
@jean-michel.houbre
@jean-michel.houbre 4 жыл бұрын
Hello, maybe i'm going to say a big nonsense, but the second method doesn't work. The line with the Lerp is executed only once, the 1st time that shakeTimer is negative. Maybe we should put something like: if (_shakeTimer
@ACBros_06
@ACBros_06 10 ай бұрын
Thank you very much. Very useful video as always
@RitleYT
@RitleYT 3 жыл бұрын
Thank you so much for this tutorial, it really helped me :) keep up the great work!
@Kn3rd5oftheRoundTable
@Kn3rd5oftheRoundTable 2 жыл бұрын
Thank you so much great tutorial!
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
I'm glad it helped you!
@RumOwnesT
@RumOwnesT 2 жыл бұрын
If all your video was like this 😍 thank you very simple and clean
@siddhant10thf70
@siddhant10thf70 3 жыл бұрын
Hey man i saw this video and i followed everything correctly...the only difference is... i am using a freelook camera...idk if that affects it but when i type the command "GetCinemachineComponent" it just doesnt verify it....I even have using Cinemachine on top.I dont know why this is happening.Please tell a solution to this.
@sila2049
@sila2049 4 жыл бұрын
Just discovered your channel and I love it!
@makemypetgamedevprocess6475
@makemypetgamedevprocess6475 3 жыл бұрын
Thanks for this awesome video, it improved the game feel of my game nicely🙏
@AlfredoAVA
@AlfredoAVA 3 жыл бұрын
Awesome tutorial, thank you so much! :D I decided to throw this functionality into a coroutine, that way Update() doesn't have to constantly check for screen shake, and so it can also be called with an Event via a public function. Would there be any significant disadvantages to doing it this way though? IEnumerator CamShake(float intensity, float time) { float shakeTime = time; while (shakeTime > 0f) { shakeTime -= Time.deltaTime; vCamPerlin.m_AmplitudeGain = intensity; yield return null; } vCamPerlin.m_AmplitudeGain = 0f; } Either way, thanks again! Your videos have helped my project immensely :)
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Yup that should work just fine
@XboxPlayerPL
@XboxPlayerPL 2 жыл бұрын
And how to reset values in lerp inside couroutine?
@chntnshrff
@chntnshrff Жыл бұрын
Wonderful tutorial. Thanks. Is it possible to make this shake in only Y axis?
@CodingKricket
@CodingKricket 2 жыл бұрын
Thanks! This helped so much!
@kendrickjba
@kendrickjba 3 жыл бұрын
hey for some reason my editor can find the CinemachineShake part of public static CinemachineShake Instance{ get; private set;}
@suryamdg
@suryamdg 2 жыл бұрын
Instead of using the singleton pattern I used it diretly in the script I wanted but even though I used getCineMachineComponent on CineMachineVirtual component it is not able to get it on awake and is showing null error
@mahdimohamadmosavi308
@mahdimohamadmosavi308 2 жыл бұрын
Great post helped me alot. Thankyou.
@chez4010
@chez4010 2 жыл бұрын
why does my character sprite keep on flickering when I add camera shake?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Are you shaking with X rotation on a 2D game? If so you might have sorting issues
@chez4010
@chez4010 2 жыл бұрын
@@CodeMonkeyUnity Fixed, thx.
@KineticProduction
@KineticProduction 6 ай бұрын
@@chez4010 how did you fix ? can you share solution ?
@lucassivolella
@lucassivolella 3 жыл бұрын
Thanks for the video! I have one issue that I can't get rid of. I'm doing a 2D game, but I made my Virtual Camera setup just like yours, besides the fact that my camera is only supposed to shake when my Player collides with another collider. When I start the game, the camera is already shaking. If I collide with something it stops shaking, and after this the camera shake works properlly. I tryed to initialize the game with Intensity and Frequency set to 0, but this messes up the camera big time. The camera starts to rotate, and the whole scene turns into a mess. Any ideias on how to fix this?
@lucassivolella
@lucassivolella 3 жыл бұрын
I know that ShakeCamera method is not called upon game initialization. Could this mean that the issue is in the hierarchy configuration?
@lucassivolella
@lucassivolella 3 жыл бұрын
I fixed it for the moment. I Serialized a NoiseSettings variable and assigned 6D Shake to it. Back at the CinemachineShake script, in the Awake method, I set the Noise Profile to null. Then, when I collide with something and call the ShakeCamera method I set the Noise Profile to the 6d Shake using the Serialized NoiseSetting. It fixed the issue I had, but I'm curious to know your ideas, since you know a lot about Cinemachine.
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Do you have "Save During Play" ticked? If so and you end the game while it is shaking then it will continue shaking when you restart.
@lucassivolella
@lucassivolella 3 жыл бұрын
@@CodeMonkeyUnity I did not have it on.
@ciceAX7
@ciceAX7 3 жыл бұрын
Hi had the same issue, and solved it. My Setup was a MainCamera and with the cm vcam as a child to it. This caused the main camera to rotate. After disconnecting them (just moving them in the hierarchy so that the cm vcam was not under the main cam but instead outside) this solved the issue.
@ygorishikawa285
@ygorishikawa285 2 жыл бұрын
Nice! Excellent video, thanks!
@justusforan
@justusforan 2 жыл бұрын
Thank you for this one. Turns out the cinemachine impulse events only fire if there is a box collider, not a mesh or convex collider. This is the missing piece...now to translate this into visual scripting.
@yeeeetsssusdelets
@yeeeetsssusdelets 4 ай бұрын
what if you want to have multiple shakes? so lets say a small shake when an enemy is hit and a big shake for e.g. an "earthquake"? if the big shake is long, then the small shake would just override the big shake
@peterparkour2918
@peterparkour2918 3 жыл бұрын
This was very helpfull, thank youuu!!
@MrMagicznyMAG
@MrMagicznyMAG 3 жыл бұрын
Thanks for this tutorial!
@user-hz4tc2pf3x
@user-hz4tc2pf3x 4 жыл бұрын
Pixel perfect with cinemachine?
@TheVicRulz
@TheVicRulz Жыл бұрын
Nice, that was easy!
@collapseboi7847
@collapseboi7847 4 жыл бұрын
Thanks sir for the tutorials
@lucafernandez1881
@lucafernandez1881 Жыл бұрын
Hey Code Monkey! Great Tutorial, i was wondering, this works when i have more than one cinmeachine camera? I have to add the shake script to the other ones?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Yes you need to add the script and noise to all your virtual cameras If working with multiple cameras you might want to look into the Cinemachine Impulse method instead
@JPasi97
@JPasi97 2 жыл бұрын
Love the video really helpfull, keep it up
@bars9803
@bars9803 4 жыл бұрын
Oh gosh that's so nice thank you!
@christophmuller1556
@christophmuller1556 3 жыл бұрын
Thanks for the tutorial, the lerping part for some reason isn't working for me though. And yes, I changed it to = Mathf.Lerp(startingIntensity, 0f, 1-(shakeTimer/shakeTimerTotal)); Why doesn't it work?
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Use Debug.Log to see what shakeTimer and shakeTimerTotal are doing Essentially that third parameter should start at 1 and go down towards 0
@XboxPlayerPL
@XboxPlayerPL 2 жыл бұрын
It doesn't work for me either. It just snaps the value to 0.
@Mr.SilentOne
@Mr.SilentOne Жыл бұрын
You most likely forgot to remove part of the if statement. It should look like: private void Update() { if (shakeTimer > 0) { shakeTimer -= Time.deltaTime; CinemachineBasicMultiChannelPerlin cinemachineBasicMultiChannelPerlin = cinemachineVirtualCamera.GetCinemachineComponent(); cinemachineBasicMultiChannelPerlin.m_AmplitudeGain = Mathf.Lerp(startingIntensity, 0f, 1 - (shakeTimer / shakeTimerTotal)); } }
@voodoojediknight
@voodoojediknight Жыл бұрын
The reason it is snapping to 0 and never gets called again because the if statement at the top of Update is checking for shakeTimer > 0 so the Lerp is done once when shakeTimer 0 doesn't pass and that's the end of the execution for the code.
@user-em9su3dd9y
@user-em9su3dd9y 3 жыл бұрын
Thanks for this!
@Walter_Hartwell_White356
@Walter_Hartwell_White356 2 жыл бұрын
Super Useful! thx
@mathew3267
@mathew3267 2 жыл бұрын
How would you change the profile? I want to use one of the Handheld profiles when I'm not shooting.
@Kaldrin
@Kaldrin 2 жыл бұрын
Thank you!
@antn908
@antn908 4 жыл бұрын
If I want to apply this to several virtual cameras, how would I go about doing so? I use a Cinemachine Clear Shot because I'm switching between cameras when entering a area, would I just manually put the script on every camera or could I place it in the Clear Shot? Thanks for a nice tutorial!
@antn908
@antn908 4 жыл бұрын
I just found out how to do this and even though it took me a while to figure out, it was a really easy process once I knew what to do. I'm thinking about making a tutorial video about it because it's really useful information but it's just not very talked about.
@kaynac825
@kaynac825 4 жыл бұрын
@@antn908 I would like to know, I was wondering that myself. This method works great but I'm noticing it does not like to transfer over to the next virtual cam. Mind sharing the knowledge? :D
@kaynac825
@kaynac825 4 жыл бұрын
@@antn908 Well, actually I have two cameras set up. It will go over to the second one and work but when I come back to the first one it won't. Like the Instance does not update. Hmm..
@kaynac825
@kaynac825 4 жыл бұрын
@@antn908 Yea. Nevermind. That was it lol. Adding it to Update().
@antn908
@antn908 4 жыл бұрын
@@kaynac825 Sure but I'm bad at explaining through text so I'll go into more detail in a video and show what I did there. At first I was looking into if I could use a script on the clear shot to apply the shake function to whatever camera that was currently live, but on some forum post one of the cinemachine devs had said something along the lines of -that's no good, use impulses for shakes-. I hadn't heard about the impulse function before and I couldn't find much about it but turns out Cinemachine Impulse is a really versatile tool that allows you to customize shakes and feedback a bunch of ways. There's a script in Cinemachine called CinemachinImpulseSource that does what the same thing as Code Monkeys script does, call it from your shoot function. (Sorry, I got this to work at 3am and I haven't slept well at all so I'm not feeling very good right now. I'll try to put up a video showing what I did soon. Hope this was of some help though.)
@jamesthewelsh
@jamesthewelsh 2 жыл бұрын
Hi Code Monkey - I've been following your 3rd person controller videos (they're brilliant). Just wanted your thoughts on what was the best way to implement a CineMachine camera shake when using the 3rd person controller - with regards to the aiming. Firstly have you covered this in any other video? If so just po In those tutorials you are using a second camera to blend between Player Follow and Player Aim. The problem comes because the virtual camera responsible for player aim is always targeting the position in front (the debug ball). I believe its recentering the camera and wildly affecting the shake effect. Any thoughts? Perhaps a 3rd Camera needs to be introduced for Solely camera shake? Cheers, James 🥰
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Hmm interesting, perhaps the issue is because that camera is set with 0 smoothing, so even if you shake it will instantly go back to the correct position. Maybe one solution would be to dynamically add smoothing while the shake is active? Or use a shake profile that moves the camera instead of rotates it
@utkugokalp3179
@utkugokalp3179 3 жыл бұрын
Very good video and really easy to understand explaining. Great work!
@ZiplawDev
@ZiplawDev 4 жыл бұрын
Please make a full tutorial on Cinemachine :)
@T5mpler
@T5mpler 4 жыл бұрын
He has
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
I covered Cinemachine here kzfaq.info/get/bejne/g9Joo9d_ysveo4k.html
@ZiplawDev
@ZiplawDev 4 жыл бұрын
@@CodeMonkeyUnity yeah, but you said it's an introduction, and I see barely any advanced tutorials on anything game related, everything just scratches the surface. I'd like to see like a giant tutorial on every component of CM and the API
@RustThisWorld
@RustThisWorld 3 жыл бұрын
Great tutorial thanks. I'm interested in what you do at 4:49, creating a public instance to be easily referenced in other scripts. Do you have any other videos detailing this?
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
It's called the Singleton pattern Very useful when you have a single instance of a specific class. They have some downsides so use them but dont abuse them!
@xudee
@xudee 2 жыл бұрын
@@CodeMonkeyUnity Thanks for the tutorial! Can I use this method when I have lots of virtual camras, and I just want the active one to shake?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
@@xudee Sure, only the one you're accessing will change
@johnnylapinator9649
@johnnylapinator9649 3 жыл бұрын
thank you Le Code Monke
@draggmaste
@draggmaste 3 жыл бұрын
hm... This is not really working for me :/ But I have three cams atm stored in a StateDrivenCamera, is there a way to ad screenshake to all of them simultaniously? Edit: well, I made it work, I just did the same thing but for all cameras instead of one, alittle clunky but worked.
@MesaTheAalfa
@MesaTheAalfa 4 жыл бұрын
YOUR ONE OF THE BEST!!! if by any chance you upload courses on Udemy I'll make sure to be your good student
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Awesome! By finishing your game you're taking a very important step! Keep it up and keep learning, best of luck!
@MesaTheAalfa
@MesaTheAalfa 4 жыл бұрын
@@CodeMonkeyUnity Thank you and I will 🤩🤩✨✨
@BastianHodapp
@BastianHodapp 3 жыл бұрын
Very nice, thanks :)
@arfcentral1911
@arfcentral1911 4 жыл бұрын
Hey everybody, for some reason I seem to run into this error after doing the first part of the tutorial before he used Mathf.Lerp... "NullReferenceException: Object reference not set to an instance of an object CinemachineShake.ShakeCamera (System.Single intensity, System.Single time)". I can't seem to find a solution to this error, does anybody know how to fix this? Thanks : )
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Use Debug.Log(); to figure out what is set to null
@sophielin5669
@sophielin5669 4 жыл бұрын
I had this problem too. I figured out I was using the wrong code. Make sure to put CinemachineBasicMultiChannelPerlin multChanPerlin= virtualcam.GetCinemachineComponent(); and include the virtualcam.GetCinemachineComponent part in both the shake function and update!
@kej1n
@kej1n 4 жыл бұрын
Maybe i'm quiet late but, if you wasn't paying attention (like i did some minutes ago) : you have to put the shakeCamera script on the CinemachineVirtualCamera.. Yeah it's late i should go to sleep yeah...
@noobatron9046
@noobatron9046 3 жыл бұрын
@@kej1n i know i'm late but you sir saved me... I was too dumb to figure it out -_- Thank you! It seems we all have that problem that we forget to add the script to an object
@paradox7336
@paradox7336 3 жыл бұрын
Loved the tutorial but I am having an issue because I am not being able to set the cinemachine component to the script cinemachineVirtualCamera.GetCinemachineComponent(); can someone help me?
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Why can't you set it? Did you add using Cinemachine?
@paradox7336
@paradox7336 3 жыл бұрын
@@CodeMonkeyUnity I did add using cinemachine. I truly have no idea why that is, my editor just doesn't show the option. Btw thanks for responding :)
@yuriaugusto1084
@yuriaugusto1084 4 жыл бұрын
Great tutorial as always i wondering if there's any way to shake the virtual camera without getting jittering? i have my onw shake script based on GDC camera shake and i would like to implement thoose concepts in cinemachine but LateUpdate don't override cinemachine position....
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Cinemachine takes control of the camera so if you have another script also moving the camera then both of those will be fighting for control Your best bet is probably to disable cinemachine while shaking and reenable it afterwards
@durrium
@durrium 3 жыл бұрын
Nice vid! Sometimes it feels like you are over complicating stuff with your coding though
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
What do you mean by overcomplicating? Any specific example?
@durrium
@durrium 3 жыл бұрын
@@CodeMonkeyUnity maybe it's just me but wouldn't it be more "easy to understand" making a coroutine with the timer? Or is that less performant or something?
@durrium
@durrium 3 жыл бұрын
And also might just be since you speed up the coding that messes with my head😅
@dencen178
@dencen178 3 жыл бұрын
Is this going to work with a cinemachine free look camera too?
@MrSmoofist
@MrSmoofist 4 жыл бұрын
For some reason it insist i did not reference the code, cant find the reason why
@diegoantunes3419
@diegoantunes3419 4 жыл бұрын
Hey man, can you make a video showing best way to create Cinematics in Unity and how to put it in-game at decisive points like empty coliders or other technics?
@hugh._
@hugh._ 4 жыл бұрын
Thanks!
@Luciferdelight
@Luciferdelight 2 жыл бұрын
Thnx so much =)
@fedechaotix
@fedechaotix 3 жыл бұрын
Very helpful. Problem is when i trigger the cam shake... my camera doesn't go back to its original position :S
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Untick "Save in Play Mode"
@minibubblegum5108
@minibubblegum5108 3 жыл бұрын
ty very much
@onuroguz940
@onuroguz940 3 жыл бұрын
im the 1000th person liked this video
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Thanks for the like!
@wizardjo
@wizardjo 2 жыл бұрын
There is any way to do this using the Cinemachine Impulse listener feature ? Thank you guys
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Yup that is the other method, just add a impulse listener on the virtual camera, then on any object add a impulse source and through code generate the impulse
@pittherichkid
@pittherichkid 2 жыл бұрын
nice one !
@rauljerilara
@rauljerilara Жыл бұрын
Why create an Instance for ShakeCamera and not only put in an object and then call the method?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Just so you can easily call the function from anywhere without having to drag references
@T5mpler
@T5mpler 4 жыл бұрын
Hey this is a very nice tutorial! Can you also tell how to do it smoothly with the normal Camera component? Ik there's one called EZCameraShake but I want to know how to do it smoothly and manually eithout tools
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
The manual way is simply just modifying the camera.transform.position with a basic Random.Range(); or more complex with some Perlin noise
@T5mpler
@T5mpler 4 жыл бұрын
@@CodeMonkeyUnity alright thank you
@T5mpler
@T5mpler 4 жыл бұрын
@@CodeMonkeyUnity Hey btw I think it would be cool if you covered Unity Timeline in a video
@connorwilson-long1336
@connorwilson-long1336 2 жыл бұрын
I keep getting the error "Use of unassigned local variable 'cinemachineBasicMultiChannelPerlin" as well as some other errors to do with the mutilchannelperlin. Help.
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Sounds like you defined the variable but never assigned it to any value. Are you doing GetCinemachineComponent()? The code on line 15 and 16 at 3:44 is all in one line.
@Abazel
@Abazel 2 жыл бұрын
Hi, I tried my best to follow this but I keep getting an error saying "NullReferenceException: Object reference not set to an instance of an object" at this line "CameraShake.Instance.Shake(5f, 0.1f);" and the camera then doesn't shake
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Always add some Debug.Log to verify what is null unitycodemonkey.com/video.php?v=5irv30-bTJw In that case it can only be the Instance field, maybe you don't have the CameraShake component attached to any object? Maybe you're calling that on Awake before the CameraShake Awake runs?
@Abazel
@Abazel 2 жыл бұрын
@@CodeMonkeyUnity I think I may have found the problem, I forgot to add “instance = this”
@juanpabon4254
@juanpabon4254 2 жыл бұрын
Thank you thank you thank you and thank you :) ,.. bro, a question. Why when changing cameras, I go from VCam 1 to Cam 2, I disable Vcam 1 because I am on Vcam2. But when I go back to Vcam 1 and enable, it doesn't work anymore, it's like sticking to VCam2. Because I go back to VCam2 and it keeps working but VCam1 no longer after the change. Any idea?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Each virtual camera has a priority setting, the system checks for all enabled virtual cameras and uses the one with the highest priority. If they have the exact same priority then I'm not sure how it's chosen
@juanpabon4254
@juanpabon4254 2 жыл бұрын
@@CodeMonkeyUnity Thanks bro, I made some priority changes and it doesn't work. I think it is an instance issue, I don't know if it has to make the file static. Because I see that camera 2 keeps registering changes, but camera 1 is as if it is not sending the parameters. As if the camera file did not receive it. Do you think it has to see the gameobject that is in memory at that moment? how I clean the memory logged by the static file, you know? Edit: I forgot to say that: My game is type (Celeste) one camera for each room, and the shaking is transmitted by an enemy stone that falls in each of the rooms, that is, there are 2 rooms with 2 enemy stones. But apparently the instance stays in room 2 when I return to room 1.
@juanpabon4254
@juanpabon4254 2 жыл бұрын
@@CodeMonkeyUnity I forgot to say that: My game is type (Celeste) one camera for each room, and the shaking is transmitted by an enemy stone that falls in each of the rooms, that is, there are 2 rooms with 2 enemy stones. But apparently the instance stays in room 2 when I return to room 1.
@shrit-th7go
@shrit-th7go 3 жыл бұрын
Heyy man love your videos , but can you put your visual studio to dark theme don't know about you but my eyes will blast open
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Sorry but my eyes burn with dark mode
@shrit-th7go
@shrit-th7go 3 жыл бұрын
@@CodeMonkeyUnity Well then you should visit your doctor (no offense, don't want to be rude I am)
@shivamprajapati6839
@shivamprajapati6839 4 жыл бұрын
Nice video
@seppukun208
@seppukun208 3 жыл бұрын
Hmmmm.... I wonder how slow the CinemachineVirtualCamera.GetCinemachineComponent() function is. Probably negligible but I still cache mine. Thanks for the tips
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Yup you should definitely cache that value when using this system in a proper game.
@statusgrabber8398
@statusgrabber8398 Жыл бұрын
Sir, I am getting "Null reference exception" error in the line where we get CinemachineBasicMultiChannelPerlin component. Please help sir!
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Did you attach that extension to the cinemachine? Maybe you added a different type of noise, each type has a different class name
@statusgrabber8398
@statusgrabber8398 Жыл бұрын
@@CodeMonkeyUnity Sir, I have added MultiChannelPerlin type. Is there's something else that I am doing wrong?
@MegaGuanxi
@MegaGuanxi Жыл бұрын
How to deal with multiple cameras and transitioning between them? For some reason when I have Cam 1 working, and I transition to a new room with another camera, the script stops working.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
If you have multiple cameras you need to access the script directly instead of through the static instance, that field will only reference the last script
@MegaGuanxi
@MegaGuanxi Жыл бұрын
@@CodeMonkeyUnity I'm sorry I'm still super new to coding. How would I access the script directly?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
@@MegaGuanxi Maybe make a SerializeField private and drag the reference unitycodemonkey.com/video.php?v=pD27YuJG3L8
@cauabozano742
@cauabozano742 3 жыл бұрын
MUITO OBRIGADOOOOOO!!!!!!!!!!!!!
@bilqinm
@bilqinm 2 жыл бұрын
thnx bro
@Videogueimeiro
@Videogueimeiro 3 жыл бұрын
Hey there, first of all, thanks for the tutorial! I need help with something though. After the camera shake, the camera stays slightly out of position and with a slight rotation, and i can't find a way to make it return to it's original position, as cinemachine camera takes control of everything. Thanks in advance!
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
If you set both parameters to 0 the virtual camera will go to the base position. If that one is still offset then the issue is on your normal parameters
@michaelshollaj6428
@michaelshollaj6428 3 жыл бұрын
I had that problem too, but I changed this line of script (1-(shakeTimer/ shakeTimerTotal)) I changed it to (0.1f - (shakeTimer/ shakeTimerTotal)) , I think this will solve it
@SirKingKrab
@SirKingKrab 3 жыл бұрын
@@CodeMonkeyUnity What do you mean by setting both parameters? The noise component or in the script itself? I'm trying to figure out the issue that was mentioned above with the rotation getting offset after the shake ends. I can't set the rotation directly on the cam because cinemachine is doing its own thing with that according to what I've read.
@theonly647
@theonly647 3 жыл бұрын
Is it 3D project?
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Works both in 2D and 3D
@theonly647
@theonly647 3 жыл бұрын
@@CodeMonkeyUnity Thanks, but what about old videos?
@albikroalperen
@albikroalperen Жыл бұрын
The positions of objects may be offseted a bit after a rough shake. Any solutions?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Objects? This only shakes the camera, it doesn't touch any object. And as the shake goes down the camera should reset to it's regular position.
@albikroalperen
@albikroalperen Жыл бұрын
Yes, the camera. I used WaitForSeconds for the time. And the "2" value for frequency. When I use shake effect for a few times, I see that my in-game cursor is not matched with my actual cursor (Without shakes, they should be matched). So its offsetted. I meant that actually.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
​@@albikroalperen But nothing here moves any object other than the camera, so whatever issue you have is in some other code, not in this cinemachine camera shake. Maybe it's something with how you're positioning that in-game cursor, maybe the camera still has some rotation after shaking.
@albikroalperen
@albikroalperen Жыл бұрын
@@CodeMonkeyUnity Maybe its about the frequency, which value would you advice for minimum problem? As I said I tried 2.
@albikroalperen
@albikroalperen Жыл бұрын
@@CodeMonkeyUnity Hey, I found the solution! I saw that every time it shakes, it changes the rotation of my camera. So I wrote a code that changes rotation values to 0 in update. Problem solved!
@jordanthebestlass8483
@jordanthebestlass8483 2 жыл бұрын
can't find the "CinemachineShake" when using cinemachine. maybe this tutorial needs an update? i'm using unity 2020
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Not sure what you mean, that script was created at 2:30 in the video, it's not a built-in thing
@jordanthebestlass8483
@jordanthebestlass8483 2 жыл бұрын
@@CodeMonkeyUnity i was following your tutorial, and when i tried typiing in "CinemachineShake," it wasn't in the dropdown that appears. sorry for the misunderstanding.
@TheJungaBoon
@TheJungaBoon 3 жыл бұрын
Hi, thanks for the tutorial! I was able to get it working up until the actual shaking part. I can trigger the shake via script, but for some reason, the camera will not return back to its default position after the shake is done. Any ideas as to why that is?
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Is the camera set up to follow a point? I'm not sure the shake resets correctly if the camera does not have a move and aim target
@TheJungaBoon
@TheJungaBoon 3 жыл бұрын
@@CodeMonkeyUnity Hi, thanks for the reply. I managed to get the shake working. One thing I was wondering though: Is there a way to pause the shake if I set Timescale to 0 using a pause menu? At the moment, whenever I pause the game, the camera just keeps rotating in one direction, then snaps back to where it should be as soon as I unpause it.
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
@@TheJungaBoon If Cinemachine is using Time.unscaledDeltaTime then changing timeScale wont affect it. One way you can do it is maybe make a simple script that tests timeScale and when it's 0 disable the cinemachine component and when its not 0 re-enable it.
@TheJungaBoon
@TheJungaBoon 3 жыл бұрын
@@CodeMonkeyUnity Thanks a bunch! That fixed my problem!
@Nounsi_Dev
@Nounsi_Dev 9 ай бұрын
Hello dude, idk if you would repy to this but my rotation is off after the shaking. how did you fixed it, i try a lot of different way but still no result
@raphaloco
@raphaloco 4 жыл бұрын
Can you teach how to make a simple android game like "Florence" in the playstore, i have music studio and artists but i still learning to work with unity, can you help?
@Coconasty
@Coconasty 3 жыл бұрын
Hi, how can i do this using a button? because when i press it, it keeps shaking and it doesn't stop
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
The function doesnt care where it's called from. You can call it from a button or key input or collision or anything.
@Coconasty
@Coconasty 3 жыл бұрын
@@CodeMonkeyUnity It worked!!!! Thank you
@feliscape
@feliscape 3 жыл бұрын
public static CinemachineShake Instance { get; private set; } That doesnt work for me. It doesnt except CinemachineShake because: "the type or namespace 'CinemachineShake' could not be found'
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
Did you name the class exactly CinemachineShake?
@feliscape
@feliscape 3 жыл бұрын
@@CodeMonkeyUnity I didnt. I just called the instance CamShake (like the class) now. Thanks!
@Thrymbor
@Thrymbor 2 жыл бұрын
i got a weird bug. when iu use this effect everytime i shoot, it starts to tilt the world at some point O.o
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
That depends on which shake type/profile you use, some only shake on some axis, some have rotation and others don't
@Thrymbor
@Thrymbor 2 жыл бұрын
@@CodeMonkeyUnity I used the same like u and the camera is permanent in tilted position. i used the same as u in the video
@simonbahamonde7370
@simonbahamonde7370 Жыл бұрын
I have a problem using this shake, on a 2D game worked perfectly but now trying in 3D it looks really wobbly after build (played on the editor looks nice tho)... does anyone have any clue on how to solve the wobbliness
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Look at the Shake type profile that you're using, there are multiple presets, some shake on and rotate on all angles, others only XZ
@simonbahamonde7370
@simonbahamonde7370 Жыл бұрын
@@CodeMonkeyUnity Thank you! I'll give it a look, it was weird since in the build for mobile and web looked fine, but only in windows looks weird after building!
@moon..9852
@moon..9852 Жыл бұрын
can i used this code with cinemachinefreelook????
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Sure, you can shake any cinemachine camera type
@kushalbaid
@kushalbaid 4 жыл бұрын
Hey 1st cool video bring more
@a.technology1446
@a.technology1446 4 жыл бұрын
Great
Screenshake that doesn't suck
8:37
Jump Trajectory
Рет қаралды 26 М.
English or Spanish 🤣
00:16
GL Show
Рет қаралды 7 МЛН
Schoolboy Runaway в реальной жизни🤣@onLI_gAmeS
00:31
МишАня
Рет қаралды 4 МЛН
Underwater Challenge 😱
00:37
Topper Guild
Рет қаралды 39 МЛН
这三姐弟太会藏了!#小丑#天使#路飞#家庭#搞笑
00:24
家庭搞笑日记
Рет қаралды 87 МЛН
How to Make a Good 2D Camera
11:38
Game Maker's Toolkit
Рет қаралды 400 М.
Easily Control Cameras with Cinemachine in Unity!
12:20
Code Monkey
Рет қаралды 94 М.
SCREEN SHAKE in Unity using Cinemachine  | Scalable | Easy
11:13
Sasquatch B Studios
Рет қаралды 10 М.
Tierlisting the BEST (and worst) GAME ENGINES
33:51
BiteMe Games
Рет қаралды 218 М.
Steam EXPERT teaches you Game Marketing for SUCCESS!
52:22
Code Monkey
Рет қаралды 59 М.
Easy Cinemachine Built-In Screen Shake - Unity Tutorial
18:26
CAMERA SHAKE in Unity
9:28
Brackeys
Рет қаралды 520 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 707 М.
I Made My First Game in Godot in 3 Weeks...
26:21
Jack Sather
Рет қаралды 321 М.
English or Spanish 🤣
00:16
GL Show
Рет қаралды 7 МЛН