๋ฐœ์‚ฌ ์œ„์น˜๋Š” ๋งˆ์šฐ์Šค ์œ„์น˜๋กœ ์˜๋Š”๋ฐ

ํŒŒํ‹ฐํด์˜ ๋ฐœ์‚ฌ๊ฐ๋„๋Š” ์Šคํ”„๋ผ์ดํŠธ ๊ทธ๋Œ€๋กœ ๋‚ ๋ผ๊ฐ€๋Š”๋ฐ ์Šคํ”„๋ผ์ดํŠธ์˜ ๊ฐ๋„๋Š” ๊ณ ์ •๋˜์žˆ์Œ...

ํ˜น์‹œ ์ด๊ฑฐ ์Šคํฌ๋ฆฝํŠธ๋กœ ์Šคํ”„๋ผ์ดํŠธ ๊ฐ๋„ ์กฐ์ ˆ๋„ ํ•ด์•ผํ•จ? ํŒŒํ‹ฐํด ์‹œ์Šคํ…œ์— ๋”ฐ๋กœ ์˜ต์…˜์ด ์žˆ์Œ?


BulletParticle.cs (ํŒŒํ‹ฐํด ์ดํŽ™ํŠธ์— ์ ์šฉ)

public class BulletParticle : MonoBehaviour
{
public float maxShotDelay;
public float curShotDelay;
public ParticleSystem particleSystem;
List<ParticleCollisionEvent> colEvents = new List<ParticleCollisionEvent>();
private void Start() {
particleSystem = GetComponent<ParticleSystem>();
}
private void Update() {
Fire();
Reload();
}

private void OnParticleCollision(GameObject other) {
int evnets = particleSystem.GetCollisionEvents(other, colEvents);

Debug.Log("HIT");
for(int i = 0; i < evnets; i++){

}

}
void Fire(){
if(!Input.GetButton("Fire1"))
return;
if(curShotDelay < maxShotDelay)
return;
if(Input.GetButton("Fire1")){
particleSystem.Play();
}
curShotDelay = 0;
}
void Reload(){
curShotDelay += Time.deltaTime;
}
}


move.cs (๋นจ๊ฐ„ ํ๋ธŒ์— ์ ์šฉ)

public class move : MonoBehaviour
{
ย  ย  float angle;
ย  ย  Vector2 target,mouse;
ย  ย  private void Start() {
ย  ย  ย  ย  target = transform.position;
ย  ย  }
ย  ย  void Update()
ย  ย  {
ย  ย  ย  ย  mouse = Camera.main.ScreenToWorldPoint(Input.mousePosition);
ย  ย  ย  ย  angle = Mathf.Atan2(mouse.y - target.y,mouse.x - target.x) * Mathf.Rad2Deg;
ย  ย  ย  ย  this.transform.rotation = Quaternion.AngleAxis(angle-90, Vector3.forward);
ย  ย  }
}