Tag Info

New answers tagged

0

I eliminated the script's start function and just called the components in the update function. var bc = blueCube.GetComponent<PlayerMovementScript>(); var rc = redCube.GetComponent<PlayerMovementScript>(); if (Input.GetButton ("Switch")) { bc.enabled = !bc.enabled; rc.enabled = !rc.enabled;


0

As you said it was working fine, i found this thing different than other inside Update function: bc.enabled = !bc.isActiveAndEnabled; Is this logic should works on isActiveAndEnabled instead of enabled ?


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 ...



Top 50 recent answers are included