- Home /
Colliders in a first controller character
HI. I am new in this amazing multi-platform game engine. My course required to do something with unity, i would like to ask you whether is possible the main character(first controller character)of my game when approaches a game object, this specific object starts playing music and after the character moves away of the object the music stops. Can you give me some hints how it can be done?
Thanks so much.
Answer by AlucardJay · Sep 25, 2012 at 09:13 PM
Here is a list of tutorials to get you going :
Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/essential-skills/
Start at the bottom and work up : http://www.unity3dstudent.com/category/modules/beginner/
the Unity Wiki : http://wiki.unity3d.com/index.php/Tutorials
A list of resources : http://answers.unity3d.com/questions/12321/how-can-i-start-learning-unity-fast-list-of-tutori.html
This particular video answers your question : http://www.unity3dstudent.com/2010/07/beginner-b01-basic-collision-detection/
and the script reference : http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html
as a trigger not collider : http://www.unity3dstudent.com/2010/07/beginner-b13-trigger-collision-detection/
and the script reference : http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html
Or of course you could just simply check the distance between the objects, if distance is less than threshold then play, else stop.
There is another cool command that could be useful here , Physics.OverlapSphere , but it is probably left until you have more experience : http://docs.unity3d.com/Documentation/ScriptReference/Physics.OverlapSphere.html
Make sure to use the scripting reference alot, use the little search box at the top-left : http://docs.unity3d.com/Documentation/ScriptReference/
Your answer
![](https://koobas.hobune.stream/wayback/20220613081504im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Car Camera help needed please 1 Answer
How to make camera position relative to a specific target. 1 Answer
Changing the camera when clicked on a collider 1 Answer
Smooth Camera 2 Answers