- Home /
camera detect collision
hi..
im having trouble to detect collisions of 2 objects with a camera..
let me illustrate...
i have 2 objects A and B .. and a camera..
when A and B collide it triggers the camera to do something like move, zoom, etc..
the camera detects the collision (my guess is raycasting).
how can this be done..??
Whaaaa.........t?
So 2 Objects, both set to isTrigger??
Camera detects the trigger for some reason??
Passing a variable is far less complicated and intensive as raycast/hit/deter$$anonymous$$e/return
function OnTriggerEnter(other:Collider)
{
if(other.name=="Object2")Camera.main.GetComponent(Script).RunCollisionFunction();
}
@zerox911 - could you edit your question and make the title meaningful - this is a knowledge base.
Answer by zerox911 · Jul 11, 2012 at 03:47 AM
so.. here's what i did...
in the trigger function..
i put in a variable for the camera..
next thing i did was..
in one of the objects (A) which contains the trigger function..
so..
here's my snippet solution..
function OnTriggerEnter(other:Collider){
var cam : Camera.main;
if(other.gameObject.tag == "B"){
//something happens to B
cam.GetComponent(objectScript).Something();
}
}
Answer by zerox911 · Jul 10, 2012 at 10:13 AM
ok..
i've found the solution..
anyway..
thanks for your patience...
Glad you found it - but could you post the solution here too?
Your answer
![](https://koobas.hobune.stream/wayback/20220613073913im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camera collision detection. 0 Answers
Receiving information about getting hit by a Raycast 2 Answers
Best method to detect sword hits 1 Answer
move camera when it collides with a trigger 1 Answer
Can someone modify this for me? 0 Answers