protected virtual void Shot() { if (bulletTemplate == null) { return; } GameObject newBullet = (GameObject)Instantiate(bulletTemplate); Utils.AssignTransformFromTo(this.gameObject.transform, newBullet.transform); Rigidbody2D rb2D = newBullet.GetComponent <Rigidbody2D> (); Vector2 newBulletVelocity = this.gameObject.transform.up * bulletSpeed; Rigidbody2D_ex.SetScaledVelocity(rb2D, newBulletVelocity); AddComponentsToBullet(newBullet); }
protected void Move(Vector2 movement) { Rigidbody2D rb2D = this.gameObject.GetComponent <Rigidbody2D> (); if (rb2D == null) { return; } float movementMultiplifier = Speed * GetModifierValue(ShipModifierType.smtMoveSpeed); Rigidbody2D_ex.SetScaledVelocity(rb2D, movement * movementMultiplifier); rb2D.position = new Vector2( Mathf.Clamp(rb2D.position.x, zone.xMin, zone.xMax), Mathf.Clamp(rb2D.position.y, zone.yMin, zone.yMax) ); }