반응형
Notice
Recent Posts
Recent Comments
«   2024/03   »
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
31
Archives
Today
Total
관리 메뉴

Do Something IT

[Unity3d]오브젝트 간 충돌을 막고 싶을 때.. 본문

Unity3D

[Unity3d]오브젝트 간 충돌을 막고 싶을 때..

아낙시만더 2013. 4. 25. 11:44
반응형

출처: 바로가기

1) Layer 단위로 충돌을 막을 때..


 Layer를 생성 & 셋팅 하고, 충돌을 안하고 싶은 레이어들을 셋팅해 준다.


Physics.IgnoreLayerCollision(LayerMask.NameToLayer("MonsterBody"), LayerMask.NameToLayer("MonsterBody"), true); 


위 소스는 MonsterBody끼리 충돌을 방지한다.

예를들어 플레이어가 박스등에 부딪히고 싶지 않다면..


Physics.IgnoreLayerCollision(LayerMask.NameToLayer("Character"), LayerMask.NameToLayer("Box"), true); 


이런 식으로 하면 된다.



참조1 : http://devkorea.co.kr/bbs/board.php?bo_table=m03_qna&wr_id=20010&sca=UNITY&sfl=wr_subject%7C%7Cwr_content&stx=%EC%B6%A9%EB%8F%8C&sop=and&page=2&currentId=44


참조2 : http://www.devkorea.co.kr/reference/Documentation/ScriptReference/Physics.IgnoreLayerCollision.html




2) 각 개체(오브젝트)별로 충돌을 (실시간으로)막고 싶을 때..

  플레이어가 몬스터와 충돌되다가 몬스터를 죽이면 충돌이 안되게 하고 싶어서 이걸 사용했다.

  처음에 Collider 자체를 껐더니 바닥과도 충돌이 안돼서 빠지는 문제 때문에 이걸로 바꿨다.


Physice.IgnoreCollision() 함수를 쓴다.


static function IgnoreCollision (collider1 : Collider, collider2 : Collider, ignore : bool = true) : void


collider1과 collider2를 충돌하지 않게 해준다.


자세한 사항은 아래 참조로..


참조 : http://www.devkorea.co.kr/reference/Documentation/ScriptReference/Physics.IgnoreCollision.html

반응형
Comments