- Home /
How to get a camera to collide with objects
I'm having a problem getting the camera in my game to collide with walls and other large objects. I have made a collision sphere around the camera and colliders around the objects but it still does not even register that it is colliding with them. Does anyone have any good ideas of why this is happening or any tips that can help with this?
Answer by Ashkan_gc · Feb 16, 2010 at 05:22 AM
you should enable the "is trigger" property of each collider and then it will call OnTriggerEnter when collides to something. also you can use ray tracing for camera movement. it's not always needed and is heavier than normal collision checking but use it if you need it.
Answer by runevision · Feb 16, 2010 at 09:50 AM
If your camera is a first person camera, the collider of the character itself should be enough. However, if your camera is somwhere else, you need a separate collider for it. It seems like you got that far.
In order for the collider on the camera to correctly collide with other colliders, the camera needs to have a rigidbody, and you need to only move the camera with physics, and not set its transform position directly. So you can use AddForce on the camera rigidbody to control it, or just set it's velocity.
Answer by Sebas · Feb 16, 2010 at 01:05 AM
Easiest solution would be to use the First Person Controller which comes as a Standard Asset with your Unity installation.
If this doesn't work and you need a customized solution, check this part of the documentation and read up on collider combinations. You havee plenty of options (Static Colliders, Rigidbody, IsKinematic, etc.) and the effects of each option are displayed in a table under "Advanced".
I second this, i see no point in using a camera as a person, when you could use the default First Person Controller.
Your answer
Follow this Question
Related Questions
How to get A Camera Collision? 1 Answer
Why are my bullets acting as being deflected by the camera borders collider? 0 Answers
Why does the screen start spinning? 2 Answers
3rd Person camera collision 2 Answers
Camera Rotation 2 Answers