void Awake() { normalShot = new NormalShot(ShotSpawnPoint, NormalBolt); fireShot = new FireShot(ShotSpawnPoint, FireBolt); makeClone = new MakeClone(gameObject, ClonePlayer); makeBarrior = new MakeBarrior(Barrior, ShotSpawnPoint); mateorShot = new MateorShot(gameObject, Mateor); gravityShot = new GravityShot(ShotSpawnPoint, Gravity_Set); }
private void Shoot() { Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); Vector2 mousePos = mouseRay.origin + mouseRay.direction; Vector2 shoulderPos = transform.parent.parent.parent.position; float distance = Vector2.Distance(mousePos, shoulderPos); float radius = 2f; if (distance < radius) { Vector2 fromShoulderToMouse = mousePos - shoulderPos; mousePos = shoulderPos + (fromShoulderToMouse.normalized * radius); } // Create shot object GravityShot shot = Instantiate(gravityShotPrefab); shot.gameObject.name = "Shot (" + gravityDirection + ")"; shot.InitShot((Vector3)mousePos - transform.position, gravityDirection); shot.transform.position = transform.position; }