Should moving cameras have rigidbodies?
Idle, nitpicking question here. I'm building a first person character controller from a rigidbody and when I was setting up the camera, started to wonder if I should add a rigidbody to the cam too, in order to avoid rebuilding the graph, to allow some movement tricks, etc.
I'm guessing the answer is NO (as inheriting y rotation from parent body is easier than getting the rigidbodies to line up w/player input, as an example), but I'd started to get so much into the habit of using Rigidbodies for ANYTHING that moved/required collision (and moving/rotating through moveposition/moverotation) that I figured I'd ask. Anybody got a best practice?
--Rev
Your right, I would say its a bad idea to add a rigid body to a new setup, though if you want to put some time into making sure the rigidbody doesnt conflict with your player in any way, but want to keep the rigid body on the camera, only for the purpose of, if you hit a wall, the camera wont clip through the wall, but you may need to add code to allow the camera to snap back to the players focus, otherwise it will just stay dodging the wall, even when you have moved passed it.
Im sure theres a better way to do stuff like that, you probably could do it all by code by just simply using a sphereCollider, with a trigger, and checking the trigger for tags of an object like a wall, and simply working the camera around the location of the wall, but rotating to still be focused on the player.
Doubt that cameras clipping through walls will be an issue, as I've set my cam near clipping plane to .1 and the cam is located within the 'head area' of the body capsule collider.
I just kept worrying that Unity would have to keep redraw the level graph a bit due to the camera moving a little independently of the body (I intend adding some anticipation / inertia effects with the cam in relation to the body velocity (also fov, etc)).
Thanks for having a think about this, though! I'm in the middle of ripping out the rb code on the camera...!
Your answer
Follow this Question
Related Questions
How to fix player camera shaking 0 Answers
Rigidbody Character Controller - Why Mouse Air Control? 0 Answers
I can't seem to get this movement + automatic lookat the direction of movement work for a 2.5D game 0 Answers
When attaching my custom camera script camera shakes when player starts to move fast. 1 Answer
Rigidbody sticks to wall 0 Answers