Moving a object when player enters trigger and play a sound

30666-moveontrigger.png

Hello, what i want to do is have the Player enter a box collider that activates some object and then applies force to that objects rigidbody so that it moves abit and then stops, kinda like a ghost paranormal event. I also want a sound to be played on entering the box collider. I also dont want the object to teleport from a to b, i just want it to have some movement when i enter a trigger and then stop.
What do i use lerp? or what ?

I will be doing this “paranormal event” many places so i need to be able to drag my object from scene into the inspector so i would need a variable in top of the script.

Please help :slight_smile:

This is very basic stuff which can easily be found by a simple Google search. You would use “Unity - Scripting API: MonoBehaviour.OnTriggerEnter(Collider)” to know when he player has entered the collider. Then you could use “Unity - Scripting API: Vector3.forward” to move the object forward. For the sound you could use

audio.Play();

or

audio.PlayOneShot();

Again look at the documentation first “Unity - Scripting API: AudioSource:smiley: Next time you should either check the Unity Scripting documentation first or Google your question before asking question on Unity Answers. But now you know :smiley: