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”);
}
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.
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…