I want to make if statement that says “after 3 seconds have passed delete the object” so I tried using deltaTime like this:
if (Time.deltaTime = 3)
{
Destroy(gameObject);
}
but I get these 3 errors
could someone show me the proper way to do this?
I want to make if statement that says “after 3 seconds have passed delete the object” so I tried using deltaTime like this:
if (Time.deltaTime = 3)
{
Destroy(gameObject);
}
but I get these 3 errors
could someone show me the proper way to do this?
To destroy your object after 3 seconds, you can just do this:
Destroy (gameObject, 3);
Also, your if statement is complaining because you’re assigning instead of comparing. You want to use == not =.
Oh! And that’s in general… either way you wouldn’t do this with Time.deltaTime.
http://unity3d.com/support/documentation/ScriptReference/index.Keeping_Track_of_Time.html
Thank you, that worked perfectly!