I have object A colliding with object B. I would like this collision to be detected and to use the detected collision to control a servo motor to move left.
Answer by Commoble
5 days ago
The OnCollisionEnter, OnCollisionStay, and OnCollisionExit event can be used in a script to perform actions during collisions; there are also similar events for Trigger interactions, and seperate events for collisions and triggers with 2D physics. For more details on this subject, refer to the Unity Manual's section on Colliders, and the Unity Tutorials on Physics.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
4 People are following this question.
Can't click gameobject when over another trigger?
Collision With Trigger, Then Add Points To Counter, Then Destroy
Reaching a gameobject from its collider
Sword Kills Enemies From Far Away
Rigidbody + Multiple Trigger Colliders - OnTriggerEnter - Get which Collider triggered the event issue