Hi, I am new to Unity and messing with some concepts. I’m bit confused about creating objects in Update()
function. I wrote a simple code where I used conditional statement to create a vector2 object and next frame the condition stop working. Even though the condition stop working but the rigidbody.velocity
is still updating. What I assume is that, during first frame new Vector2
object is created and after first frame it keeps updating the value through the object not the Update() Am I right?
Here’s the code.
bool a = true;
void Update()
{
if (a)
{
Debug.Log("Velocity");
rigidbody.velocity = new Vector2(1,0);
a = false;
}
}