What's on the outside of your functions matters just as much as what's on the inside. Optimizing the amount of information passed around between functions ensures that you'll never find a bridge that you can't code across. Perform the following steps to capture data:
Move your function call from the
Update
function back to theStart
function and reset the translation value to2.0f
. For learning purposes, imagine that yourStart
function needs to know how far theMoveObject
function moved the text to the right. We already know that the movement value is a float, so we can change the return type fromvoid
tofloat
. Your function should now look like the one shown in the following code:float MoveObject () { gameObject.transform.Translate(2.0f, 0.0f, 0.0f); }