{"id":359,"date":"2018-11-20T23:59:59","date_gmt":"2018-11-20T14:59:59","guid":{"rendered":"http:\/\/reasty.net\/?p=359"},"modified":"2018-11-20T23:59:59","modified_gmt":"2018-11-20T14:59:59","slug":"unity-basic-parts-2-2","status":"publish","type":"post","link":"https:\/\/reasty.net\/?p=359","title":{"rendered":"Unity basic parts (3) &#8211; 3D \ucd1d\uc54c\ud53c\ud558\uae30 \uac8c\uc784 \ub9cc\ub4e4\uae30(2)"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-393 size-large\" src=\"http:\/\/192.168.10.240:8080\/wp-content\/uploads\/2018\/12\/Dodge_2-1024x555.png\" alt=\"\" width=\"625\" height=\"339\" srcset=\"https:\/\/reasty.net\/wp-content\/uploads\/2018\/12\/Dodge_2-1024x555.png 1024w, https:\/\/reasty.net\/wp-content\/uploads\/2018\/12\/Dodge_2-300x163.png 300w, https:\/\/reasty.net\/wp-content\/uploads\/2018\/12\/Dodge_2-768x416.png 768w, https:\/\/reasty.net\/wp-content\/uploads\/2018\/12\/Dodge_2-1536x832.png 1536w, https:\/\/reasty.net\/wp-content\/uploads\/2018\/12\/Dodge_2.png 1920w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/p>\n<p>\uc774\uc81c\ubbfc \uac15\uc0ac\ub2d8\uc774 \uac15\uc758\ub0b4\uc6a9 \uacf5\uc720\ud574 \uc8fc\uc2dc\ub294 \uc0ac\uc774\ud2b8.<br \/>\n<a href=\"https:\/\/boxcollider.io\" target=\"_blank\" rel=\"noopener\">boxcollider.io<\/a><\/p>\n<p>Unity Project : \ud3f4\ub354\uae30\ubc18\uc73c\ub85c \ud558\ub098\uc758 \ud504\ub85c\uc81d\ud2b8\uac00 \uad00\ub9ac\ub418\uba70, \uad00\ub9ac\ub418\ub294 \ud3f4\ub354\ub294[Assets,Packages,ProjectSettings] \uac00 \uc788\ub2e4.<\/p>\n<p>[Collider].<strong>Is Trigger<\/strong> : \ucda9\ub3cc \uac10\uc9c0\uc5ec\ubd80<br \/>\n&#8211; Checked : \ucd1d\uc54c\ub07c\ub9ac\ub294 \ubd80\ub52a\ud788\uc9c0 \uc54a\uc544\uc57c \ud55c\ub2e4. \uae30\ubcf8\uc801\uc73c\ub85c \ub6ab\uace0 \uc9c0\ub098\uac00\uc57c\ud568.<br \/>\n<strong>\ucda9\ub3cc\uac10\uc9c0, \uc0c1\ub300\ubc29\uc744 \ubc00\uc5b4\ub0b4\uc9c0\ub294 \uc54a\uc9c0\ub9cc \ucda9\ub3cc\uac10\uc9c0\ub294 \ud55c\ub2e4.<\/strong><br \/>\n\ubb3c\ub9ac\uc801\uc778 \ubc18\ubc1c\ub825\uc740 \ud544\uc694\ud558\uc9c0 \uc54a\uc744\ub54c \uc0ac\uc6a9\ud55c\ub2e4.<\/p>\n<p><strong>\uc720\ub2c8\ud2f0\uc758 \uba54\uc138\uc9c0 \uae30\ubc18 \ud568\uc218\ub4e4<\/strong>. Start(), Update(), &#8230;<\/p>\n<p>OnTriggerEnter(\uc0c1\ub300\ubc29 \ucf5c\ub77c\uc774\ub354) \ub458 \uc911 \ud558\ub098\ub77c\ub3c4 Rigidbody\ub97c \uac00\uc9c0\uace0 \uc788\ub2e4\uba74 \uba54\uc138\uc9c0\ub97c Broadcasting.<\/p>\n<blockquote><p>\uc720\ub2c8\ud2f0 \uac1c\ubc1c\uc790\ub294 \ucda9\ub3cc \uadf8\uc790\uccb4\ub97c \uad6c\ud604\ud558\uae30\ubcf4\ub2e4 <strong>\ucd9c\ub3d9\uc744 \uac10\uc9c0\ud588\uc744\ub54c \ubb34\uc5c7\uc744 \ud560\uae4c<\/strong>\uc5d0 \uc9d1\uc911\ud55c\ub2e4.<\/p><\/blockquote>\n<p>Rigidbody : \uac8c\uc784\uc624\ube0c\uc81d\ud2b8\uc5d0 \ubb3c\ub9ac\uc601\ud5a5\uc744 \ubc1b\uc744 \uc218 \uc788\uac8c\ub054 \ud55c\ub2e4.<\/p>\n<p>FindObjectOfType() : \ub9ce\uc774 \uc4f0\uba74 \uc548\ub428. Scene \uc5d0 \uc874\uc7ac\ud558\ub294 \ubaa8\ub4e0 \uac8c\uc784\uc624\ube0c\uc81d\ud2b8\ub97c \uac80\uc0c9\ud558\uae30 \ub54c\ubb38.<\/p>\n<p><strong>Time.deltaTime<\/strong> : \uc9c1\uc804\uc758 Update()\uac00 \ud638\ucd9c\ub41c \uc2dc\uac04\uc73c\ub85c\ubd80\ud130\uc758 \ud750\ub978 \uc2dc\uac04. \uc2dc\uac04\uac04\uaca9<\/p>\n<p>UI (2D)\ub3c4 \uac8c\uc784 \uc624\ube0c\uc81d\ud2b8\uc774\ub2e4.<br \/>\nEventSystem : \uc0ac\uc6a9\uc790\uac00 \uc785\ub825\uc744 \uac00\ud588\uc744\ub54c, \uadf8 \uc785\ub825\uc744 \ub2f9\ud588\uc744\ub54c \uadf8\uac83\uc744 \uc54c\ub824\uc8fc\ub294 \uc5ed\ud560\uc744 \ud55c\ub2e4.<br \/>\n\uc54c\uc544\uc11c \ub3d9\uc791\ud568. UI\uc694\uc18c\ub4e4\uc5d0\uac8c \uc785\ub825\uc744 \ub2f9\ud588\uc744\ub54c \uc54c\ub824\uc900\ub2e4.<\/p>\n<p><strong>Canvas<\/strong>: \ubaa8\ub4e0 UI\uc694\uc18c(2D)\ub4e4\uc758 \ubd80\ubaa8\uc774\ub2e4.<\/p>\n<p><strong>Rect Transform, Anchor Presets<\/strong> \ub97c \ub20c\ub7ec \uc124\uc815\ud560\ub54c Alt \ub97c \ub20c\ub7ec \uae30\uc900\uc810\uacfc \ud568\uaed8 \uc704\uce58\ub97c \ubcc0\uacbd\ud55c\ub2e4.<\/p>\n<p>\uae00\uc0c1\uc790\ubcf4\ub2e4 \uae00\uc790\uac00 \ucee4\uc11c \uc548\ubcf4\uc77c\ub54c, Alignment : middle, center,<br \/>\nHorizontal Overflow : overflow, Vertical Overflow : overflow (\/wrap:\uc790\ub974\uae30)<br \/>\n\uc798\uc548\ubcf4\uc774\uba74, shadow \ub610\ub294 outline component\ub97c \uc801\uc6a9<br \/>\nAdd Component, UI, effects<\/p>\n<p><strong>Prefab<\/strong> : Bullet\ub97c Assets\ub85c \ub4dc\ub798\uadf8&amp;\ub4dc\ub78d\ud558\uba74 Prefab \ud615\uc2dd\uc73c\ub85c\ub418\uba70, \uc7ac\uc0ac\uc6a9 \uac00\ub2a5\ud558\ub2e4.<\/p>\n<p>[Canvas].Scaler<br \/>\nUI Scale Mode : \uae30\uc900\ud574\uc0c1\ub3c4\ub97c \uc124\uc815. Scale With Screen Size, Constant Pixel Size,\u00a0Constant Physical Size<br \/>\nMatch : Width;\uac00\ub85c\ub294 \uc9e4\ub9b4\uc218 \uc788\uace0 \uc138\ub85c\ub294 \uc548\uc9e4\ub9b0\ub2e4.<\/p>\n<pre class=\"lang:c# decode:true\" title=\"LoadScene\">\/\/ \ud604\uc7ac Scene\uc5d0 \uc874\uc7ac\ud558\ub294 \ubaa8\ub4e0 \uac8c\uc784 \uc624\ube0c\uc81d\ud2b8\ub97c \ud30c\uad34\ud558\uace0, \uc0c8\ub85c\uc6b4 Scene\ub97c \ub85c\ub529\ud55c\ub2e4.\nstring sceneName = \"SampleScene\";\nSceneManager.LoadScene(sceneName);<\/pre>\n<p><strong>PlayerPrefs<\/strong> : \uc0ac\uc6a9\uc790 \uc124\uc815\uc744 K,V \ud615\ud0dc\ub85c \ub85c\uceec \ud30c\uc77c\uc5d0 \uc800\uc7a5\ub41c\ub2e4. \ud0a4\uac00 \uc5c6\uc73c\uba74 Type\uc758 \uae30\ubcf8\uac12\uc744 \ubc18\ud658\ud55c\ub2e4. \ubcf4\uc548\uc740 \uc57d\ud558\ub2e4. \ud574\ud0b9\uc5d0 \uc704\ud5d8\uc774 \uc788\ub2e4.<\/p>\n<p>Dodge \uac8c\uc784 \uc18c\uc2a4<br \/>\n<a href=\"https:\/\/github.com\/reastykim\/SVVR-Dodge\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/reastykim\/SVVR-Dodge<\/a><\/p>\n<pre class=\"lang:c# decode:true \" title=\"Bullet\">public class Bullet : MonoBehaviour {\n    public float speed = 8f; \/\/ \ucd1d\uc54c \uc774\ub3d9 \uc18d\ub3c4\n    \/\/ \uc774\ub3d9\uc5d0 \uc0ac\uc6a9\ud560 \ub9ac\uc9c0\ub4dc\ubc14\ub514 \ucef4\ud3ec\ub10c\ud2b8\n    private Rigidbody bulletRigidbody;\n\n\tvoid Start () {\n        \/\/ \uc790\uc2e0\uc758 \uac8c\uc784 \uc624\ube0c\uc81d\ud2b8\uc5d0\uc11c Rigidbody\ub97c \ucc3e\uc544\uac00\uc838\uc624\uae30\n        bulletRigidbody = GetComponent&lt;Rigidbody&gt;();\n\n        \/\/ \ub9ac\uc9c0\ub4dc\ubc14\ub514\uc758 \uc18d\ub3c4 = \uc55e\ucabd \ubc29\ud5a5 * \uc18d\ub825\n        \/\/ transform\uc740 \uc790\uc2e0\uc758 \ud2b8\ub79c\uc2a4\ud3fc \ucef4\ud3ec\ub10c\ud2b8\ub97c \uc989\uc2dc\n        \/\/ \uc811\uadfc\ud558\ub294 \uc9c0\ub984\uae38\n        bulletRigidbody.velocity\n            = transform.forward * speed;\n\n        \/\/ \uc790\uc2e0\uc758 \uac8c\uc784 \uc624\ube0c\uc81d\ud2b8\ub97c 3\ucd08 \ub4a4\uc5d0 \ud30c\uad34\n        Destroy(gameObject, 3f);\n\t}\n\n    \/\/ \ud2b8\ub9ac\uac70 \ucda9\ub3cc : \uc11c\ub85c \ub6ab\uace0 \uc9c0\ub098\uac00\ub294 \ucda9\ub3cc\n    \/\/ \ud2b8\ub9ac\uac70 \ucda9\ub3cc\uc2dc \uc790\ub3d9\uc2e4\ud589 (\uc785\ub825\uc73c\ub85c \uc0c1\ub300\ubc29 \ucf5c\ub77c\uc774\ub354\uac00 \uc634)\n    private void OnTriggerEnter(Collider other)\n    {\n        \/\/ \ucda9\ub3cc\ud55c \uc0c1\ub300\ubc29\uc758 \ud0dc\uadf8\uac00 Player \uc778\uac00?\n        if(other.gameObject.tag == \"Player\")\n        {\n            \/\/ \uadf8\ub7ec\ud558\ub2e4\uba74, \uc0c1\ub300\ubc29\uc73c\ub85c\ubd80\ud130\n            \/\/ PlayerController \ucef4\ud3ec\ub10c\ud2b8\ub97c \uac00\uc838\uc624\uae30\n            PlayerController playerController\n                = other.GetComponent&lt;PlayerController&gt;();\n            \/\/ \ud50c\ub808\uc774\uc5b4 \uc0ac\ub9dd \uc2e4\ud589\n            playerController.Die();\n        }\n    }\n\n    \/\/ \uc77c\ubc18 \ucda9\ub3cc\uc2dc \uc790\ub3d9\uc2e4\ud589\n    \/\/private void OnCollisionEnter(Collision collision)\n    \/\/{\n        \n    \/\/}\n}<\/pre>\n<pre class=\"lang:c# decode:true \" title=\"BulletSpawner \">public class BulletSpawner : MonoBehaviour {\n    public GameObject bulletPrefab; \/\/ \uc0dd\uc131\ud560 \ucd1d\uc54c \uc6d0\ubcf8 \ud504\ub9ac\ud339\n    public float spawnRateMin = 0.5f; \/\/ \ucd5c\uc18c \uc0dd\uc131 \uc8fc\uae30\n    public float spawnRateMax = 3f; \/\/ \ucd5c\ub300 \uc0dd\uc131 \uc8fc\uae30\n\n    private Transform target; \/\/ \ubc1c\uc0ac\ud560 \ub300\uc0c1\n    private float spawnRate; \/\/ \uc0dd\uc131 \uc8fc\uae30\n    private float timeAfterSpawn; \/\/ \ucd5c\uadfc \uc0dd\uc131 \uc2dc\uc810\uc5d0\uc11c \uc9c0\ub09c \uc2dc\uac04\n\n    void Start () {\n        timeAfterSpawn = 0f; \/\/ \ud0c0\uc774\uba38\ub97c \ub9ac\uc14b\n        \/\/ spawnRateMin\uacfc spawnRateMax \uc0ac\uc774\uc758 \ub79c\ub358 \uac12\uc744 \uc0ac\uc6a9\n        spawnRate = Random.Range(spawnRateMin,spawnRateMax);\n        \/\/ FindObjectOfType\uc740 \uc52c\uc5d0 \uc874\uc7ac\ud558\ub294 \ubaa8\ub4e0 \uc624\ube0c\uc81d\ud2b8\ub97c \uac80\uc0c9\n        \/\/ \ud558\uc5ec \uc6d0\ud558\ub294 \ud0c0\uc785\uc758 \uc624\ube0c\uc81d\ud2b8\ub97c \ucc3e\uc544\uc634\n        target = FindObjectOfType&lt;PlayerController&gt;().transform;\n\n        \/\/PlayerController playerController\n        \/\/    = FindObjectOfType&lt;PlayerController&gt;();\n        \/\/target = playerController.transform;\n\t}\n\n    \/\/ 1\/60\ucd08 \ub9c8\ub2e4 \uc2e4\ud589\ub428\n    \/\/ 1\ud68c \uc2e4\ud589 \ub9c8\ub2e4 : timeAfterSpawn = timeAfterSpawn + 1\/60\n    \/\/ 100\ubc88 \uc2e4\ud589 -&gt; \ud604\uc2e4\uc2dc\uac04\uc73c\ub85c\ub294 100\/60\ucd08, timeAfterSpawn = 100\/60\n\n    \/\/ \uac8c\uc784 \ud654\uba74\uc774 \ud55c\ubc88 \uac31\uc2e0\ub420\ub54c \ud55c\ubc88 \uc2e4\ud589\ub428\n\tvoid Update () {\n\n        \/\/ Time.deltaTime\uc740 \uc9c1\uc804\uc758 Update\uc640 \ud604\uc7ac Update \uc2e4\ud589 \uc2dc\uc810\n        \/\/ \uc0ac\uc774\uc758 \uc2dc\uac04 \uac04\uaca9\n        timeAfterSpawn = timeAfterSpawn + Time.deltaTime;\n        \/\/ \ub204\uc801\ub41c \uc2dc\uac04\uc774 \uc0dd\uc131 \uc8fc\uae30\ubcf4\ub2e4 \ud06c\uac70\ub098 \uac19\ub2e4\n        if(timeAfterSpawn &gt;= spawnRate)\n        {\n            timeAfterSpawn = 0f; \/\/ \ub204\uc801\ub41c \uc2dc\uac04\uc744 \ub9ac\uc14b\n\n            \/\/ bulletPrefab\uc758 \ubcf5\uc81c\ubcf8\uc744 \uc0dd\uc131\n            \/\/ \uc704\uce58\uc640 \ud68c\uc804\uc740 \ucd1d\uc54c \uc0dd\uc131\uae30 \uc790\uc2e0\uc758 \uc704\uce58\uc640 \ud68c\uc804\uc73c\ub85c \uc9c0\uc815.\n            \/\/ \uc0dd\uc131\ub41c \ucd1d\uc54c \ubcf5\uc81c\ubcf8\uc744 bullet \uc774\ub77c\ub294 \ubcc0\uc218\ub85c \ub2e4\ub8e8\uae30\n            GameObject bullet = Instantiate(bulletPrefab,\n                transform.position,transform.rotation);\n\n            \/\/ \ucd1d\uc54c\uc774 target\uc744 \ubc14\ub77c\ubcf4\ub3c4\ub85d \ud68c\uc804\n            bullet.transform.LookAt(target);\n\n            \/\/ \ub2e4\uc74c\ubc88 \uc0dd\uc131\uae4c\uc9c0\uc758 \uc0dd\uc131 \uac04\uaca9\uc744 \ub79c\ub364\ud558\uac8c \ubcc0\uacbd\n            spawnRate = Random.Range(spawnRateMin, spawnRateMax);\n        }\n\t}\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc774\uc81c\ubbfc \uac15\uc0ac\ub2d8\uc774 \uac15\uc758\ub0b4\uc6a9 \uacf5\uc720\ud574 \uc8fc\uc2dc\ub294 \uc0ac\uc774\ud2b8. boxcollider.io Unity Project : \ud3f4\ub354\uae30\ubc18\uc73c\ub85c \ud558\ub098\uc758 \ud504\ub85c\uc81d\ud2b8\uac00 \uad00\ub9ac\ub418\uba70, \uad00\ub9ac\ub418\ub294 \ud3f4\ub354\ub294[Assets,Packages,ProjectSettings] \uac00 \uc788\ub2e4. [Collider].Is Trigger : \ucda9\ub3cc \uac10\uc9c0\uc5ec\ubd80 &#8211; Checked : \ucd1d\uc54c\ub07c\ub9ac\ub294 \ubd80\ub52a\ud788\uc9c0 \uc54a\uc544\uc57c \ud55c\ub2e4. \uae30\ubcf8\uc801\uc73c\ub85c \ub6ab\uace0 \uc9c0\ub098\uac00\uc57c\ud568. \ucda9\ub3cc\uac10\uc9c0, \uc0c1\ub300\ubc29\uc744 \ubc00\uc5b4\ub0b4\uc9c0\ub294 \uc54a\uc9c0\ub9cc \ucda9\ub3cc\uac10\uc9c0\ub294 \ud55c\ub2e4. \ubb3c\ub9ac\uc801\uc778 \ubc18\ubc1c\ub825\uc740 \ud544\uc694\ud558\uc9c0 \uc54a\uc744\ub54c \uc0ac\uc6a9\ud55c\ub2e4. \uc720\ub2c8\ud2f0\uc758 \uba54\uc138\uc9c0 \uae30\ubc18 \ud568\uc218\ub4e4. Start(), Update(), &#8230; OnTriggerEnter(\uc0c1\ub300\ubc29 \ucf5c\ub77c\uc774\ub354) \ub458 \uc911 \ud558\ub098\ub77c\ub3c4 Rigidbody\ub97c \uac00\uc9c0\uace0 \uc788\ub2e4\uba74 \uba54\uc138\uc9c0\ub97c&#8230; <a href=\"https:\/\/reasty.net\/?p=359\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9,11],"tags":[21,45],"class_list":["post-359","post","type-post","status-publish","format-standard","hentry","category-study","category-unity","tag-c","tag-unity"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/reasty.net\/index.php?rest_route=\/wp\/v2\/posts\/359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reasty.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/reasty.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/reasty.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/reasty.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=359"}],"version-history":[{"count":0,"href":"https:\/\/reasty.net\/index.php?rest_route=\/wp\/v2\/posts\/359\/revisions"}],"wp:attachment":[{"href":"https:\/\/reasty.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/reasty.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/reasty.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}