- Home /
How to detech collision without rigidbody
Hello. I have a game object. I write a script. I wanna make collision detechtion without rigidbody. I try but isn't work.
Provide more info, show us your script, let us know what you're trying to do. Your question as it is, can't be answered.
void OnColliderEnter(Collision collision){
if (collision.gameObject.tag=="Point")
{
point+=5;
collision.gameObject.GetComponent<PointScript>().up=true;
}
But it isn't work. How to i can make it without rigidbody..
Answer by vexe · Sep 14, 2013 at 09:53 AM
You want to walk in a collider area without using a rigidbody component attached to your game object?
Just use OnTriggerEnter and check isTrigger on your collider.
EDIT: Read this, and then this. To have collision between two of your objects one of them has to have a rigidbody
component.
If you don't want your object to react with physics due to the fact that it has a rigidbody attached to it, just check isKinematic in the rigidbody component.
From chart at bottom of Unity Docs, for OnTriggerEnter at least one collider needs a RigidBody, but it can be isKinematic if Collider.isTrigger=true. For OnCollisionEnter at least one collider needs a (regular, NOT kinematic) rigidbody. Confusing AF!
Answer by MichLad · Oct 17, 2019 at 01:43 PM
I had problems with the collision. I manually set the position, but the rigidbody caused them to constantly move due to its physics. Vexe's solution didn't work since I didn't have said isKinematic checkbox. But it did lead me to the solution.
My solution:
In a script I set:
myRigidbody.isKinematic = true;
myRigidbody.useFullKinematicContacts = true;
I didn't have the isKinematic checkbox available in the editor. But I believe that setting Body Type from 'dynamic' to 'kinematic', and checking the 'use Full Kinematic Contacts' checkbox will have the same outcome.
This is the right answer, the above one is incompleted. You need to set the rigidbody to Kinematic and set the "Use Full Kinematic Constacts" checbox to true. Here is a pic to help: