{"id":1082,"date":"2015-01-07T10:17:08","date_gmt":"2015-01-07T10:17:08","guid":{"rendered":"http:\/\/www.nikola-breznjak.com\/blog\/?p=1082"},"modified":"2015-08-16T19:54:05","modified_gmt":"2015-08-16T19:54:05","slug":"bouncing-ball-in-unity3d","status":"publish","type":"post","link":"https:\/\/nikola-breznjak.com\/blog\/codeproject\/bouncing-ball-in-unity3d\/","title":{"rendered":"How to create bouncing balls in Unity3D step by step"},"content":{"rendered":"<p>Followed this official tutorial:\u00a0<a href=\"http:\/\/unity3d.com\/learn\/tutorials\/modules\/beginner\/physics\/assignments\/bouncing-ball\">http:\/\/unity3d.com\/learn\/tutorials\/modules\/beginner\/physics\/assignments\/bouncing-ball<\/a><\/p>\n<p>My own version on <a href=\"https:\/\/github.com\/Hitman666\/BallBouncerUnity3D\">GitHub<\/a>, and you can <a href=\"http:\/\/nikola-breznjak.com\/_testings\/Unity\/Bouncer\/\">see it in action here<\/a> (watch for 10 seconds to see what happens with the balls in the way the interact).<\/p>\n<p>Steps to make this:<\/p>\n<ol>\n<li>Create a new empty <strong>3D<\/strong> project<\/li>\n<li>Save the scene as <strong>Main.unity<\/strong><\/li>\n<li>Hierarchy -&gt; Create -&gt; 3D object -&gt; <strong>Plane<\/strong><\/li>\n<li>Hierarchy -&gt; Create -&gt; 3D object -&gt;\u00a0<strong>Sphere<\/strong>\n<ol>\n<li>drag it up the <strong>y<\/strong> axis<\/li>\n<\/ol>\n<\/li>\n<li>Hierarchy -&gt; Create -&gt; Light -&gt;\u00a0<strong>Directional light<\/strong>\n<ol>\n<li>drag it up the <strong>y<\/strong> axis above the sphere<\/li>\n<li>set x rotation to <strong>90<\/strong><\/li>\n<\/ol>\n<\/li>\n<li>Click on the Sphere\n<ol>\n<li>Add Component -&gt; Physics -&gt; <strong>Rigidbody<\/strong><\/li>\n<li>Add Component -&gt; Physics -&gt;\u00a0<strong>Sphere collider<\/strong><\/li>\n<\/ol>\n<\/li>\n<li>Assets -&gt; Create -&gt; <strong>Physics material<\/strong>\n<ol>\n<li>Set <strong>Bounciness<\/strong> to 0.8 (to bounce forever set to <strong>1<\/strong>)<\/li>\n<li>Set <strong>Bounce combine<\/strong> to Maximum<\/li>\n<li>drag it to the <strong>Material<\/strong> of the Sphere collider of the Sphere object<\/li>\n<\/ol>\n<\/li>\n<li>Create a folder called <strong>Prefabs<\/strong> in the <strong>Assets<\/strong> folder\n<ol>\n<li>Drag the Cube to this folder and delete it from the Hierarchy<\/li>\n<li>Drag the prefab Cube from the Prefabs folder to the Hierarcy and you can now duplicate it with the same behavior<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Followed this official tutorial:\u00a0http:\/\/unity3d.com\/learn\/tutorials\/modules\/beginner\/physics\/assignments\/bouncing-ball My own version on GitHub, and you can see it in action here (watch for 10 seconds to see what happens with the balls&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1083,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,41],"tags":[],"class_list":["post-1082","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codeproject","category-unity3d"],"_links":{"self":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/1082","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/comments?post=1082"}],"version-history":[{"count":5,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/1082\/revisions"}],"predecessor-version":[{"id":2099,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/1082\/revisions\/2099"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media\/1083"}],"wp:attachment":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media?parent=1082"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/categories?post=1082"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/tags?post=1082"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}