- Home /
add camera collision without CharacterController
how to add collision to the camera without the use of character controler?
I made a script for the camera move what I want to happen when is I don't want the camera pass through any object, I need to prevent the camera passing through walls and gameobjects
is there any posible way to do this without the characterController component? thanks
Answer by Jehos · Nov 06, 2011 at 03:07 PM
Try adding a capsule collider to your camera.
The actual result will depend on your moving code, but the collider should prevent it to go through other colliders or rigid bodies.
It is very important to add that if you use this method, you also need a rigid body. This changes game logic and would likely require some changes to code, but an important rule is:
Never add static colliders to dynamic objects without a rigid body.
The physics engine will hate you forever and nothing will work properly without a rigid body.
I didn't know that. I though rigid bodies were used only for object that could potentially move.
So what you're saying is:
1) that if I have to create a big wall, that wall should have a rigid body?
2) Or you mean to add the rigid body to the camera because the camera does move?
I'm guess you mean (2), but just wanted to check!
Let me clarify that by dynamic objects I mean objects that (might) move. As opposed to static objects which are objects that don't move.
To answer your question. $$anonymous$$y statement is more like #2. Any object that might move needs to have a rigid body for the simulation to work accurately and efficiency.
Objects like walls and floors are fine just having a collider. They never move. But for moving objects, rigid bodies tell the Physx engine that the object is dynamic and that it needs to check to see if the object moved into another collider every cycle.