- Home /
Colliding an object
I'm taking my first steps through Unity, as a follow up to this question:
http://answers.unity3d.com/questions/56697/isometric-game-camera-limits
I now realized that I don't know how to make a collider actually collide. Now I have a GameObject I move around instead of the camera, and the camera is a child to that object. It has a box collider, and there're four other box colliders around the level so it will collide against them.. and it's not working, of course, because I was changing the position variable by hand. What do I do so this collides? use a rigidBody and apply forces to it? is there a way to put a maxVelocity on it? I can't see one, besides a rigidbody seems sort of overkill for what I'm trying to do. Otherwise I guess I just put mass 1, and export drag and force, but I'd much rather work with a maxSpeed, because drag will also affect the acceleration rate
Answer by flaviusxvii · May 05, 2011 at 05:49 PM
Mark the colliders as triggers. Attach a script to the box that moves it back into the visible area when a trigger event occurs and the other object is one of the invisible walls.
http://forum.unity3d.com/threads/68004-Camera-Trigger-Hitting-Walls
that link appears to be broken, at least it sends me to a forum thread that starts Floor Trigger To $$anonymous$$ove Camera (code attached), is this where you're sending me? OnTriggerEnter's reference says that this works only if one of the collider's also a rigidBody, can I make the static object a RigidBody?
Right you are. I'd either make the walls rigidbodies or just use OnCollisionEnter and figure it out that way.
that requires rigidbody as well. $$anonymous$$aking the walls into rigidbodies didint work, didn't think it would, because you usually need the rigidbody to be the one moving in order for the calculations to be made. $$anonymous$$aking the object the camera follows the rigidbody gets OnTriggerEnter called, but I'm still having trouble to stop the camera at the right spot..
Your answer
Follow this Question
Related Questions
Player glitching through wall when sprinting 1 Answer
2D Movement [HELP!] 0 Answers
My Raycast acts like it's hitting something when it isn't 0 Answers
How to get transform.Translate to work with rigidbodies 2 Answers
How can I make a non-player character (rigidbody) move when they touch the ground? 1 Answer