• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by rscholey · Aug 04, 2012 at 02:31 PM · collisiontrigger

Is there a way I can tell the position of a collision?

I have two objects. One is a moving wall and the other is an object that represents a person. On the wall I added a Rigidbody and checked "Is Kinetatic" is checked, I also have a Mesh Collider and I checked "Is Trigger".

I added a script to the wall and inside the OnTriggerEnter() I have a Debug.Log("Entered") which detects a collision. On the OnTriggerStay() { renderer.material.color = Color.red; } changes the wall color once the trigger has been fired. This all works and a collision causes the wall to change color.

Is there a way that I can detect the actual point on the wall where the collision happened. What I would like to do is to have some effect at that point.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by tobiasparrow · Aug 04, 2012 at 03:30 PM

Basically, OnCollisionStay gives information about the impact ( impact velocity, etc ) as where OnTriggerStay simply says, yes, we have had a collision

This will help explain them better then I can! =]

OnCollisionStay:

http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionStay.html

OnTriggerStay:

http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerStay.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Bluk · Aug 04, 2012 at 05:49 PM

I'm not sure why you want to use a trigger instead of a collider. The Collider class is specifically designed to get this kind of informations.

See: http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html http://docs.unity3d.com/Documentation/ScriptReference/ContactPoint.html

Hope it helps.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Sundar · Aug 04, 2012 at 03:07 PM

This will help you to get contact point of a collision

http://docs.unity3d.com/Documentation/ScriptReference/Collision-contacts.html

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image rscholey · Aug 04, 2012 at 03:17 PM 0
Share

Thanks. I notice this mentions OnCollisionStay. I will look into it myself but just wondering do you know the difference between the OnTriggerStay and OnCollisionStay?

avatar image fafase · Aug 04, 2012 at 03:34 PM 0
Share

Trigger disable the physics engine. It means the collision is not resolved but only detected.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

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.



Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Detection Help 1 Answer

Objects Touching? 1 Answer

OnTriggerEnter Not Working 3 Answers

Dynamic terrain (Safeground) 0 Answers

OnTrigger event when colliders are already touching eachother 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges