티스토리 뷰

유니티

AngryBird

tose33 2021. 2. 28. 10:45

- 공이 날라가면서 궤적 남기기

Trail Renderer 사용.

tose33.tistory.com/74

처음에 공의 게임오브젝트에 Trail Renderer 붙였다.

방금 날린 공은 파괴되고 다음 공이 나오기 때문에 이전의 궤적도 같이 사라짐.

공 게임오브젝트에게 자식오브젝트를 만들고 거기게 Trail Renderer를 붙인 후에, 공이 파괴될때 자식을 부모에게서 때어내면 궤적이 남는다.

// Bomb이 파괴될때 child와 parent 분리 (trail renderer 유지 위해서)
    void OnDestroy()
    {
        _trail.transform.parent = null;
    }

 

- Bird에게 가해진 충격 측정

collision.relativeVelocity.magnitude을 이용해서 Bird에게 공에 의해 가해진 강도를 측정.

private void OnCollisionEnter2D(Collision2D other)
    {

        // 충돌 강도 측정 
        Debug.Log(other.relativeVelocity.magnitude); 

        if(other.relativeVelocity.magnitude > health)
        {
            Die();
        }
	}

health보다 큰 충격이 가해지면 죽도록.

 

 

'유니티' 카테고리의 다른 글

Sendmessage no Reciever 뜨는 경우?  (0) 2021.03.01
Port  (0) 2021.03.01
Time.deltatime  (0) 2021.02.19
동적으로 부모 게임오브젝트에 상속시키기  (0) 2021.02.19
Sprite renderer, Image  (0) 2021.02.18
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함