Collision problems (onCollisionEnter)

Hallo,

I’m pretty sure that this has already been posted before so sorry about that, but I just wanted to know something.

I have two objects… A - has a box collider and riggidBod (moving around). And B - box collider only.

The onTriggerEnter method works fine, but if I try to use onCollisionEnter function then nothing happens. Its like it wouldn’t even notice that the two objects are touching. How could I fix that?

And there is no problem with the script because its the most basic script copied from the site.

Not even…
function OnCollisionEnter(){
print(“something”);
}

is working. :expressionless:

OnTriggerEnter works when the collider is a trigger.
OnCollisionEnter works when the collider is not a trigger.

It sounds like your collider is a trigger.

Make sure the isTrigger option is not ticked under the component of your collider. And use the code tag under go Advanced then a # button when you want to type a snippets. :smile:

Ok, thanks, I will try that. Also, by collider, do you mean the object that my RiggidBody is coliding with or the RBody? Or both?

By collider, we mean the Collider =P

Its another component thats attached to your GameObject.

Ok, so I played around with this and it looks like the OnCollisionEnter function works only if the object that I’m moving isn’t Kinetic… to tell you the truth… I have no idea if that is good or bad. What dos the “Is Kinetic” checkBox under the RiggidBody do?

Anyway, I got it to work, but thers one problem… if I don’t check the “Use Gravity” cb under RiggidBody then my object flies away as soon as it hits the collider and if I do check it then my my moving object might rotate around on one of the axis which isn’t something that I want. (I kinda want to do a 2,5 D game…)

Is there some way to set the global rotation of the Y axis (if I didn’t get that wrong) to stay the way it is? I tried:

transform.rotation.y = 0;

Or something like that, but it doesn’t seem to affect the object in any way once it hits the collider and starts rotating around… :s

I know that I could try to just imitate the “physics” via some script but it would be a lot easier for me to do it this way… :confused:

if isKinematic is checked, a script doesn’t affect the rigidbody (when you try to move it via code, it won’t work because of that)