Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
avatar image
0
Question by WaiYsky · Nov 22, 2016 at 01:59 PM · objectcollision detectiontriggers

Hello I'm Sky,

In my project, I want to have sound when my moving game object only if collide(pass through it) with two game object with rigidbody and a collider. Please help me fast, I need to finish by tomorrow morning. qJake@username I think you could help me :) Thank you Sir.

Comment
Add comment · Show 1
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 JatMidGrade · Nov 22, 2016 at 03:51 PM 0
Share

C# or Javascript?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by JatMidGrade · Nov 22, 2016 at 03:56 PM

Not entirely sure if I understand your question correctly, but here's an attempt at an option for you. Does it have to collide with BOTH objects to play the sound, or just one at any given point in time?

 using UnityEngine;
 using System.Collections;
 
 public class ExampleClass : MonoBehaviour {
     void OnTriggerEnter(Collider other) {
         AudioSource audio = GetComponent<AudioSource>();
         audio.Play();
     }
 }
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 JatMidGrade · Nov 22, 2016 at 03:58 PM 1
Share

If it requires you collide with both, you'll have to have some boolean values and if statements to confirm both colliders have been triggered.

avatar image WaiYsky · Nov 23, 2016 at 02:38 AM 0
Share

Thank you Jat$$anonymous$$idGrade. $$anonymous$$y logic there was a mistake. $$anonymous$$y game is to avoid the in co$$anonymous$$g object by the player. When success to avoid the in co$$anonymous$$g object then we will need to have sound. Then if my in co$$anonymous$$g object was collide my player and I don't want to trigger the sound. I only think about is either collide with my player or not, I would have sound. So could you think about a way to implement this situation.

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.

Follow this Question

Answers Answers and Comments

82 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Trouble with collison and trigger's 1 Answer

Is there a way for my to put 2 box colliders on the Same object but only have one of them check the trigger? 0 Answers

Enemy CharacterController stopped detecting all triggers, but Player's CharacterController still detects and fires the same triggers 1 Answer

OnTriggerEnter vs distance check in Update 1 Answer

Prevent changing speed at collision 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges