Motion Controller
Last updated
Last updated
If you continue looking down the hirarchy of the Player Without Weapon prefab, you will see a Camera Animator object. This is simply an example animator that animates a "camera-kick" effect when the player fires. Below that, we have Camera Motion Controller object, which has MotionController.cs component attached to it.
This motion controller is the script that handles various effects to give life to the camera object.
BobMotion: Bobs the camera with sine waves based on whether the player is walking or running.
Key & Mouse Sway: Sways the camera's rotation based on keyboard & mouse input.
Recoil Motion: Recoils camera when player fires.
Breath Sway: When player aims, enables a sway effect mimicking player moving the weapon due to breathing. Player can hold shift to stabilize.
Positioner: Can place the object to hip, aim or running position, based on whatever method is called. Is not being used in here, but will be used for weapon.
BobMotion and Key&Mouse Sway works individually, one of them is based on player movement events coming from PlayerMovementController.cs and the other one is solely based on key&mouse inputs. Recoil Motion requires you to call Recoil() method in MotionController.cs, same for using BreathSway and Positioner behaviors. Since our player prefab doesn't have a weapon now, these effects are enabled but there is no-one calling them.