Hey, i am trying to create a sniper scope with cinemachine cameras. I used basic multi channel perlin for shake effect. But when i shoot it always goes to the same position, i guess because of my cam is not changing positions for the shake. My shooting code is like that “Physics.Raycast(gunCam.transform.position, gunCam.transform.forward,out hit, range)”. Any help?
I would not use the perlin nose component for a reactive shake. Instead, use Cinemachine Impulse: Impulse | Cinemachine | 2.7.9
Do the raycast using the main camera transform to get the precise camera location. However, the main camera is updated vary late in the frame, so you have to make sure that you do the raycast after the camera has been positioned. The easiest way is to use CinemachineCore.CameraUpdatedEvent
, which is invoked after the camera has been positioned.