Translation js to C # : just one line in file

I’m actually working to translate a unity project originally in unityscript/javascript to C#. I already have translated a good part of the project, but i’m confronted to one problem :

In javascript, I have a file named KillParticle.js and in this one there is just one line :

Destroy ( this.gameObject, 1.0);

But if I’m doing the same in C#, Its throwing me an error. How to deal with that in C#? I need to implement this line in Update or Start function ?

Thanks per advance!



My KillParticle.cs :

using UnityEngine;
using System.Collections;

public class KillParticle : MonoBehaviour {
	Destroy ( this.gameObject, 1.0f);

Return : The method must have a return type. If I insert the Destroy in a function Start or Update it working but I need to implement the code in which function ?

You really should supply us with the full error message, but I assume the compiler doesn’t like you using a double instead of a float: Use 1.0f to indicate a float value in c#. (1.0 is a double - a number with twice the precision of a standard float). Also, you actually need to call Destroy() from within a method.

public class KillParticle : MonoBehaviour
	private void Start()
		Destroy(gameObject, 1.0f);

in c# you need to say what the return type of the function is so it would be

public void death()
    Destroy(gameObject, 1.0f);

where void is the return type wich means it returns nothing where you can have differnt return typs like int

private int addNumber(int a, int b)
    int x = a + b;

    return x;

I think you can use any type as a return like arrays and custom classes

but if you just want a function to do something then using void is what you want

Sorry i was ment to post this as a comment to PokePoWo’s Edit but i clicked the wrong place.