there is no debug message or anything
ontrigger is false on both
i have rigid body on both
collider on botb
made sure to spell it right 10 times
i even tried ontriggerenter still not working
when the cube collides nothing happens
One of the rigidbodies needs to be non-kinematic for it to work. Have you check that?
Also, check the collision matrix and see if the layers the objects are in can detect collisions with each other.
What type of colliders are you using? Are you using a mesh collider or a regular one? Is any of the objects marked as static? Do they ever register a collision or they just fail sometimes? Does your script inherits from monobehaviour? Have you tried with other objects and other layers? Have you try to see if other functions like collision stay are at least called? Does the object collide to the other (not letting it pass or moving it if you try to go against it).
they r box colliders
yes it is monobehavior
no i didnt try other layers nor other collision
i tried once they let collide but i changed gameobjects now they pass
both cases didnt work tho
If non works, try to give more info. Test it in a new empty scene, post images with your hierarchy and components, give more info on how you’re moving the objects during play mode. Maybe they’re beign moved too fast and Unity can’t compute it. There are phyisics options that can check faster collisions. If they’re not generating a reaction with each other, you should see why this is happening.
I have a new test project in which I have a sphere with a rigidbody in a static world of box and mesh colliders.
If the sphere leaves the ground and hits another object on its way down it will not trigger OnCollisionEnter() again making it impossible to jump. I am logging the OnCollisionEnter() and OnCollisionExit() and it seems OnCollisionExit() is called more often than OnCollisionEnter(). In the image attached you can see the sequence of events. The sphere is resting on the collider, but OnCollisionEnter() has not been called.
It checks if _collisions is over 0 to allow movement.
Could also compare colliders to a cached collider in OnCollisionExit() to see if they are different.
I think it could be improved with the option of having the events be ordered so that upon leaving an object’s collider it will be followed up by OnCollisionEnter again to make sure it is always the last event called if true for at least one object. Using OnCollisionStay() is costly for performance and I would rather avoid using that.
yah i have the same problem someone can tell me what is wrong in my scripts ?(im begginer)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[code=CSharp]using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class collision : MonoBehaviour
{
void OnCollisionEnter(Collision other)
{
if (other.gameObject.CompareTag("barrier"))
print("re");
}
}
first of all my case was that i imported an asset that added tags called collide and all objects haf to have so oncollison can be called so please check for this
is this script sitting on the object that has the collider?
I also had this problem, but I could find my emberassing error. I could not see the messages, because I deactivated the Unity messages in the console:sweat_smile:. Look if the buttons of the top-right corner are activated.