I have a game character object which is followed by camera. Camera is child object of Character.
Using rigid body makes the character tilt in slopes and camera tilts too.
how do i stop camera tilting when character tilts?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
The answer is in your second sentence.
Camera is child object of Character.
The Camera should not be a child of the character. This is what is causing the camera to tilt. A child will follow its parent's transform.
Remove the Camera from the Character. The script @Jon linked to will do what you want by modifying the camera transform, as the character moves without modifying rotation. So, your Camera shouldn't tilt at all.
If you need the camera to be a child of your character, @Jon offers another solution in the chat he links to that updates the Camera with an inverse rotation of your character.