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.
Here is a list of tutorials to get you going :
Start at the bottom and work up : Unity 3D Student - 3d Modelling
Start at the bottom and work up : Unity 3D Student - 3d Modelling
the Unity Wiki : http://wiki.unity3d.com/index.php/Tutorials
A list of resources : How can I start learning Unity fast? ( List Of Tutorials ) - Unity Answers
This particular video answers your question : Unity 3D Student - 3d Modelling
and the script reference : Unity - Scripting API: Collider.OnCollisionEnter(Collision)
as a trigger not collider : Unity 3D Student - 3d Modelling
and the script reference : Unity - Scripting API: Collider.OnTriggerEnter(Collider)
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 : Unity - Scripting API: Physics.OverlapSphere
Make sure to use the scripting reference alot, use the little search box at the top-left : Unity - Scripting API: