public void Fire(Vector2 direction) { var rotation = QuaternionUtil.FromDirection2D(direction); var bulletInstance = (GameObject)Instantiate(bullet, origin.position, rotation); bulletInstance.GetComponent <Rigidbody2D>().velocity = direction.normalized * 20; bulletInstance.GetComponent <BulletController>().ignore = ignore; }
void OnAITargetting(AIShooterInfo info) { if (info.State == AIShooterState.NOT_IN_RANGE) { this.visualElement.gameObject.SetActive(false); return; } float width = maxThickness * (1 - info.TimeToShoot / info.ShootDelay); visualElement.SetWidth(width, width); this.visualElement.gameObject.SetActive(true); this.visualElement.gameObject.transform.position = info.From; this.visualElement.gameObject.transform.rotation = QuaternionUtil.FromDirection2D(info.Target); }