Blockchain Technology has the Following Properties

In our previous Blog titled “Revolutionizing Pharma Supply Chains with Blockchain and Smart Contracts Part 1”, we discussed the FDA’s Drug Supply Chain Security Act of 2013 that addressed…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Create a Shooting Game using Augmented Reality

This tutorial will teach you how to create a 3D SceneKit model, render it in augmented reality, and apply physics collision to the object in real-time.

Xcode 9 (or later) and an ARKit supported device running iOS 11 (or later) are required to follow along.

Let's get started with the terms we are going to use frequently in this blog.

I have divided the complete implementation into steps for better clarification.

If you run the project, you will notice a ship 3D model floating in front of you.

Step-2 Let’s add assets into Assets.xcassets which we are going to use later.

Add assets

Step-3 Add Empty node from Object Library and set its position to (0,0,0) and name it container in the identity panel. This container node will be used to contain all our boxes.

Step-4 Setup the scene and add it into the view in ViewController.

Step-6 Let’s now understand the way to calculate the world coordinate system.

We are calculating the node’s(box) position as per the above vector coordinate system via box geometry as shown below.

Boxes geometry

Step-7 Now we understood how to calculate, let's add boxes as a child node in the container node we have created in Step-5 and present it to the real-world.

This is where we’ll add some physics!

For building a complete scene we need to add a sphere node to hit the boxes and explosion files to the scene for animation. You will know more information about this in further explanation.

Step-8 Perform hit test and detection

Tracker Node

Step-8 (i) To register the touch, we are using touchesBegan(). If the touch is found then place the game scene over there.

Step-8 (ii) Add this delegate to get updates when two physical bodies contact each other.

After adding child nodes to our scene’s rootNod, it will look like this.

Boxes added to the scene

Step-8 (iii) Add a ball image over boxes.

Step-9 Collision of Nodes

Step-10 Perform the collision and removing the boxes that came in contact.

Step-11 Create an explosion effect after the collision.

So basically, when the ball hits the pyramid of boxes, it shows an explosion animation that removes the boxes and adds a particle system in the system.

Step-12 Show congratulations animation after we explode all the boxes.

Here we are adding a simple view to our SceneView and we are adding a particle system to our rootNode for displaying stars animation.

Show congratulations message
Final output

Add a comment

Related posts:

Advantages and Disadvantage Of Band Saw Cutting Machine

One of the most significant benefits of a band saw is its ability to create precise cuts. You can make complicated curves, clean edges, and accurate angles with the correct blade installed. As a…

On Parenthood. The Why and Why Not

These days having a kid is not as automatic a process as it was earlier, though a good part of the process stays the same ;-). I’ve often been in conversations — mostly initiated by a woman of age to…

Cara mengatur waktu

Pernahkah kamu merasa apa yang sedang kamu kerjakan hanya selesai sedikit? Maksudnya, kamu merasa sangat lelah tapi kenyatannya apa yang dihasilkan tidak sesuai dengan lelalahmu. Kalau saya menyebut…