private void FixedUpdate() { Vector2 position = transform.position; position += direction * (BulletSpeed * Time.deltaTime); transform.position = position; ScreenWrapper.Wrap(gameObject); }
private void FixedUpdate() { // limit velocity Vector2 tempVelocity = rg2D.velocity; tempVelocity.x = Mathf.Clamp(tempVelocity.x, -MaxSpeed, MaxSpeed); tempVelocity.y = Mathf.Clamp(tempVelocity.y, -MaxSpeed, MaxSpeed); rg2D.velocity = tempVelocity; // slightly tune direction if (Random.value > 0.90f) { rg2D.rotation += Random.Range(-0.125f, 0.125f); } // wrap ScreenWrapper.Wrap(gameObject); }