void Shoot() { if (ifShoot && Time.time > lastShootTime + shootRate) { //炮塔位置(A) - 攻击对象位置(B) 得到两者之间的向量 B->A // Quaternion angle = Quaternion.identity; // angle.SetFromToRotation(shootSpawn.transform.forward, shootvector); //shootSpawn.transform.LookAt(transform.position + shootvector); //Transform bullet = spawnPool.Spawn("bullet"); //Instantiate(BulletPool.GetInstance(),shootSpawn.transform.position,shootSpawn.transform.rotation); bullet = BulletPool.GetInstanceOnPosition(shootSpawn.position, shootSpawn.rotation.eulerAngles.z); //bullet.GetComponent<Rigidbody2D>().velocity = shootvector * moveSpeed; lastShootTime = Time.time; ifShoot = false; } }
public override void Attack() { if (Input.GetMouseButtonDown(0)) { cState = CharacterState.Attack; } if (cState == CharacterState.Attack) { CameraMove.attackDirection = attackAngular; CameraMove.isShake = true; for (int i = -5; i < 6; i++) { GameObject go = shellsPool.GetInstanceOnPosition(transform.position, i * 10 + attackAngular); go.GetComponent <Rigidbody2D>().velocity = go.transform.right * fireSpeed; } _canAttack = false; cState = CharacterState.Idle; } }