Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.80/5 (5 votes)
See more:
C#
using UnityEngine;

public class PlayAudio : MonoBehaviour
{
    public GameObject audioObj;

    public void DropAudio()
    {
        Instantiate(audioObj, transform.position, transform rotation);
    }
}


What I have tried:

Just say what is wrong.
Thanks
Posted
Updated 23-Nov-21 2:19am
v2

Look at your code:
Instantiate(audioObj, transform.position, transform rotation);
                                                   ^
                                                   |
I'm pretty certain that should be a '.' not a space ...

If you look at eteh error message in Visual Studio, it shows you which line and column it found it on. Double clicking the error will take you directly to it, and it will underline the problem area in red. The error message is also pretty clear if you look closely at your code as well.
 
Share this answer
 
Comments
Johny Pikolino 23-Nov-21 8:43am    
oh i didnt look there thanks very much. :)
OriginalGriff 23-Nov-21 8:51am    
You're welcome!
(It's easy to miss: I read what I meant to write far too often ... :sigh:)
Try
C#
Instantiate(audioObj, transform.position, transform.rotation);
                                                   ^ 
You may want to follow a basic course on C#, as it is pretty standard stuff which you should be able to spot by yourself. Better know the grammar of the language before attempting to build anything with it, don't you think? :)
 
Share this answer
 
Comments
Johny Pikolino 23-Nov-21 8:44am    
Didnt look there thanks . :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900