๋ฐ์ฌ ์์น๋ ๋ง์ฐ์ค ์์น๋ก ์๋๋ฐ
ํํฐํด์ ๋ฐ์ฌ๊ฐ๋๋ ์คํ๋ผ์ดํธ ๊ทธ๋๋ก ๋ ๋ผ๊ฐ๋๋ฐ ์คํ๋ผ์ดํธ์ ๊ฐ๋๋ ๊ณ ์ ๋์์...
ํน์ ์ด๊ฑฐ ์คํฌ๋ฆฝํธ๋ก ์คํ๋ผ์ดํธ ๊ฐ๋ ์กฐ์ ๋ ํด์ผํจ? ํํฐํด ์์คํ ์ ๋ฐ๋ก ์ต์ ์ด ์์?
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);
ย ย }
}
์ต์ ๋ฐ์๋ค ์์์ผ๋ก ์คํ๋ผ์ดํธ๋ ํํฐํด ๋ฃ์ด๋๊ณ ๋ถ๋ชจ๋ง ๊ฐ๋ ๋ฐ๊บผ์ฃผ๋ฉด ๋๋๊ฑฐ์๋?
์ฝ๋๋ ์์์ ์์ฌ๋ฆฌ๋ ์ฐ๋น ์ง์ ํด์ ๋ค์ ์ฌ๋ ธ์... ํ๋ธ๋ผ๋ ์ต์ ์ ์์์ผ๋ก ํํฐํด์ ๋ฃ์ด์ ํ์. ํํฐํด ์์ฒด๋ฅผ ์ฝ๋ผ์ด๋ ์ํธ์์ฉ์ผ๋ก ์ฐ๊ณ ์ถ์ด์...
์๋ฎฌ๋ ์ด์ ์คํ์ด์ค ์๋๋ก ๋์ด์๋๊ฑฐ ์๋์ง ํ์ธํด๋ณด์