Tag Info

New answers tagged

1

I have to agree with Ben. You can do things in Update but once you start having to manage many different objects changing simultaneously it is much nicer to do it with CoRoutines. Having said that, it took me several iterations and seeing good examples in the Unity demos to feel like I understood them properly. For now, go with what makes the most sense. ...


0

Coroutines are very useful for actions like these. When programming a game you've probably found yourself wishing each object was independent with the ability to do things over time without blocking other objects from executing. To achieve this normally, we'd need a new thread for each object that exists in the game world ( which is is impractical for ...


0

manage all in the Update (I use c# and pseudo code) bool Charging=false; float timer = 2f; GameObject bomb; void Update() { ... if (Input.GetButtonDown("Fire2") && Charging==false ){ bomb = (GameObject) Instantiate(bombGO, transform.position + offset,transform.rotation); Charging=true; } ... if ...


1

You should also mention that creating objects isn't cheap performance-wise. So you should be reusing objects that you plan to have multiple of. In general any game object that is being created and destroyed over the course of the whole game should be reused and not destroyed. You can google object pooling for more information. ...


7

Destroying the object gets rid of it completely. You cannot get it back. It is gone. Deactivating it just disables it; everything is still there, it just does nothing. Therefore, if you want to reuse the object, you can deactivate it, but if you will never use it again, you should destroy it (and get back its memory).


0

The only reason this.transform works at all is because MonoBehavior implements a convenience property for the Transform component on the GameObject the behavior is attached to. ...It's rather misleading. I think gameObject.transform is more semantically correct, but that's splitting hairs. They do the same thing.



Top 50 recent answers are included