• 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 /
This question was closed Oct 20, 2012 at 10:19 AM by Fattie for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by KoshX87 · Oct 20, 2012 at 09:56 AM · convert

Cannot convert "System.Type" to "UnityEngine.AudioClip"

My code which will be below is one that I wrote from scratch and from what I can tell it should be working, but it doesn't because of the following error which don't fix no matter what I try. The purpose of the audio code is probably unimportant because it is just the error I want to fix but I'll tell you. I'm making a spawning script and at the start I want it to say that there are 30 seconds left until the spawning will take place and then another audio clip when the monsters begin to spawn to tell the player that the monsters are spawning. I have tried the below method and i tried the exact same thing with audio.PlayOneShot(audioclip)( without the audio.clip = audioclip before it) but that didnt work either and it had some other error about no audio source, but i would appreciate it if someone can tell me how i can fix the audio problem because i couldn't find a solution to this error online.

 var unitToSpawn: GameObject;
 var spawnPoint: Transform;
 var wayPoint: Transform;
 var waveNumber: int = 1.0;
 
 var numberOfUnitsOnField: int = 0;
 
 var thirtySecondsUntilSpawn = AudioClip;
 var monstersHaveSpawned = AudioClip;
 
 
 function Start(){
     //Play this so that the player knows to be ready
     audio.clip = thirtySecondsUntilSpawn;
     audio.Play();
     //The initial 30 seconds of wait time before the monsters spawn
     yield WaitForSeconds(30);
     audio.clip = monstersHaveSpawned;
     audio.Play();
     //Spawn the first wave.:
     if (numberOfUnitsOnField ==0){
         var numberOfUnitToSpawn: int = ((waveNumber * 2)+ 5);
         while (numberOfUnitToSpawn > 0){
             //spawn one monster every 0.5 seconds until wave is complete
             yield WaitForSeconds(0.5);
             var instance:GameObject = Instantiate(unitToSpawn, spawnPoint.position, spawnPoint.rotation);
             numberOfUnitToSpawn = numberOfUnitToSpawn -1;
             //not sure if a rigidbody is necessary for lerp to work or not
             instance.AddComponent("Rigidbody");
             instance.position = Vector3.Lerp((spawnPoint.position),(wayPoint.position),  5 * Time.deltaTime);
         }
         waveNumber +=1;
     }
 }

thanks in advance for any help and i will make sure that i will reply and select the correct answer asap. =]

Comment
Add comment
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

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by KoshX87 · Oct 20, 2012 at 10:18 AM

I actually figured out my problem it was that i put = instead of :, but now i have a different problem. Can anybody tell me how to make my instantiabled objects go to the wayPoint because it just stands still. I tried adding a force to the rigidbody but that is not effecient because it won't stop when it reaches the waypoint(which is actually the only waypoint)

Comment
Add comment · Show 1 · 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 Fattie · Oct 20, 2012 at 10:19 AM 0
Share

you must start a new question. well done on thart solve!

Go for it with a new question.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

Converting file types 1 Answer

Converting 'char' to the name of a variable 1 Answer

Easier way to remap mouse axis / keyboard input to iphone joysticks? 0 Answers

Convert To UnityScript 1 Answer

C# to Unity script question ? 4 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