Error with "Destroy(gameObject, PlaySound(0).length);"
How do I fix these errors ? The .' operator cannot be applied to operand of type
void' Argument #2' cannot convert
object' expression to type float' The best overloaded method match for
UnityEngine.Object.Destroy(UnityEngine.Object, float)' has some invalid arguments
using UnityEngine;
using System.Collections;
public class BlueSquareCollision : MonoBehaviour {
public AudioClip[] audioClip;
void OnCollisionEnter2D(Collision2D collision2D)
{
if (collision2D.transform.name == "BlueWall")
{
Destroy(gameObject, PlaySound(0).length);
}
}
PlaySound may be a function, you may want to try to get that sound as a clip and then get its length. $$anonymous$$aybe audioClip[0].length
?
Answer by MythralFTW · Nov 19, 2015 at 08:06 PM
You probably wanted to do
Destroy(gameObject, PlaySound[0].length);
Note that it is Square Brackets not Parentheses, Parentheses implies a function, Square Brackets will access the value of an array.
Your answer
Follow this Question
Related Questions
AddListener issue C# 0 Answers
Need Help with a match 3 style game 0 Answers
Help me ! Unity Mana !,HELP ME MANA! 0 Answers
3D Space Shooter C# tutorial 1 Answer