Time for action – give up the func
Let's get that function set up in the EnemyShip Script first. Double-click to open the EnemyShip Script, and get typing.
Write this new function outside of and apart from the other functions in the script:
function ResetPosition(){ transform.position.y = 71; transform.position.x = Random.Range(-11, 68); transform.position.z = 0; rigidbody.velocity = Vector3.zero; }
These are the very same repositioning lines we already have. You can even just type the shell of the function, and copy/paste those lines right in there. Either way, you need to go back and eradicate those lines from the
Update
function and replace them with aResetPosition()
function call.Erase these bolded lines:
if(transform.position.y < -4) { transform.position.z = 0; transform.position.y = 71; transform.position.x = Random.Range(-11, 68); rigidbody.velocity = Vector3.zero; }
And replace them with the
ResetPosition()
function call:if(transform.position.y <...