- Home /
Collision not working at all [ABANDONED]
Ok, I'm getting a little pissed off because I can not for the life of me get this to work! I have a simple box (WITH COLLIDER) that is supposed to move towards a sphere (AGAIN WITH COLLIDER). Neither of them are triggers.
When the box hits the sphere, its supposed to print out "HIT!" in the debug log. Instead, it doesn't do anything but shake around. (I know its supposed to shake, but its not registering a collision at all).
I have looked at every tutorial I can find with no luck. here is the code for the box:
var target1 : Transform;
var target2 : Transform; var which = true;
function Update () {
if (which == true){
transform.LookAt(target1);
}else{
transform.LookAt(target2);
}
transform.Translate(Vector3.forward * Time.deltaTime * 3);
}
function OnCollisionEnter(collisionInfo : Collision){ //which = false; Debug.Log("HIT!"); }
Any Ideas? I don't want to use Rigid Bodies since neither the box nor the sphere are supposed to be physics objects.
thankyou.
Answer by Eric5h5 · Jun 03, 2011 at 05:59 PM
You have to use rigidbodies if you want collisions to work. See the chart on the bottom of this page.
I know you can do it without using rigid bodies. I just want the computer to see that two objects are touching each other. I don't want them to bounce off eachother or anything like that
@$$anonymous$$echWarrior117: you can't do it without using rigidbodies. But it sounds like you want triggers, not collisions.
Answer by Tasarran · Jun 03, 2011 at 07:46 PM
You can make the objects RigidBodies, then toggle the Is Kinematic on.
This means that they will have access to the RigidBody functionality, but they won't be affected by physics, just controlled by scripting.
Answer by Meltdown · Jun 03, 2011 at 06:24 PM
If you don't want to use rigidbodies you'll need to to mark your objects as triggers.
Then use OnTriggerEnter to do your collision detection.
If I'm not mistaken, setting them as 'is trigger' will also disable the physics of the collision (it won't stop or bounce), but you'll get the OnTriggerEnter event so you can handle that yourself.
As he states in a comment below Eric's answer, he doesn't want anything bouncing off anything, her just wants a collision intersection to register :p
ok, so I made both colliders (sphere and Cube) triggers and used OnTriggerEnter, but I'm still not getting the Debug $$anonymous$$essage! Thank you all so much for your help :) but I am still having trouble.
$$anonymous$$ech, did you ever resolve this? If not I'll make you a test project to show you how its done. You're definately missing something.
Answer by youmu42 · Jun 03, 2011 at 07:24 PM
You could have two colliders per object: One set for the physics(regular) and one for the collision detection(trigger). This would also give you the flexibility to change the hit detection for difficulty adjustment without getting different physics as a result.
Your answer
Follow this Question
Related Questions
Objects placed manually collide, but don't if instantiated? 1 Answer
Collisions - bounce of walls but not from characters (while still reacting with them) 0 Answers
Can't add Rigidbody component because collision prevents it 2 Answers
Collider2D/RigidBody2D not working 1 Answer
Possible to stop collider from "popping" through plane when re-centering? 2 Answers