I set up a timer, but im told i need a get or set accessor. that part of it is where im told that right before the first timer
void update
{
timer += 1.0F * Time.deltaTime;
if (timer >= 4){
GameObject.Destroy(gameObject);
}
}
I set up a timer, but im told i need a get or set accessor. that part of it is where im told that right before the first timer
void update
{
timer += 1.0F * Time.deltaTime;
if (timer >= 4){
GameObject.Destroy(gameObject);
}
}
More importantly, why ask on a documentation forum?
The correct forum is the Scripting forum. Also, always use code-tags when posting code please. You can also edit your post for this.
Note that C# is case-sensitive. Unity calls a method named “Update” (note the U).
I’ll move your post for you.
For this is already created method by Unity.
This should work.
float timeToDestroy = 1f;
void Start()
{
Destroy(this.gameObject,timeTodestroy);
}
Some times ago i created simple script with player and enemy, if you go with player by WASD inside purple circle enemy will shoot you.You can see in my code how it work just import package into your project.