top of page
Search

Learn the Android NDK Fundamentals

  • Writer: Analia peter
    Analia peter
  • Jun 3, 2022
  • 5 min read

Provided you're a seasoned programmer, creating your first Virtual Reality app might be a breeze if you have the correct tools. This tutorial will give you a head start on creating a virtual reality app for an Android phone.


You should start with something simpler before attempting to create your own first-person VR shooting or racing game. We'll walk you through the beginning steps of creating a small VR experience in this post.


Step 1: Obtaining the Required Equipment

Augmented reality environments may be created with a variety of technologies. Despite the fact that you are free to use whatever tool you like, Unity3D is one of the most popular tools for creating virtual reality solutions, thus it will be utilised here. Another excellent incentive to use it is that it is free to use until you start making money from your solutions.


You'll be able to design a VR app for Android with a programme like Unity, but you'll also be able to target a range of other devices with a few adjustments to the build settings. For many developers, the ability to combine Unity with Visual Studio for scripting solutions is another major selling point.


This is where you can locate and download Unity3D.


Unity3D is being used.

Unity3D should be started after it has been installed. When you do, you'll be met with a page identical to Figure 1's opening page.


Screenshot of the Unity3D Intro

The Unity3D Intro screen is shown in Figure 1.


You may click the New icon, which is shown in Figure 1, from the intro screen. As illustrated in Figure 2, this will bring up a box for naming and saving your project.


Choosing a Name for Your Unity Project

Figure 2: Naming your Unity Project


You should name your project and choose the place where you want the files to be saved. As you can see in Figure 2, I've given the project the name VR-Android-Style. My project is saved in a Unity project folder. Within ProjectUnity, a sub-folder with the project name will be generated when the project is created.


You should double-check that the Template option is set to 3D. Unity may also be used for 2D and other types of projects. Obviously, you'll be targeting 3D for the Android VR solution you're constructing from this post.


After you've chosen your preferences, click the Create project button to start working on your blank project. This might take a few seconds or minutes to load, depending on the power of your equipment. Once it's loaded, you should see something like Figure 3 as the default Unity layout. The editor has a lot to offer; however, you'll only need to deal with a portion of it at first!


Your project's default Unity layout

Figure 3: Your project's basic Unity layout


Using Unity to target Android

Unity will by default target a desktop solution. As a result, to target Android, you'll need to change a few development parameters. Select File -> Build Settings in the editor.... The Build Settings dialogue will appear as a result of this action.


Unity's build options

Figure 4: Unity's build options


A list of systems that can be targeted can be found in the build settings dialogue. The Standalone mode for PC, Mac, and Linux will most likely be featured. To target Android, go to the platforms list and choose Android, then click the Switch Platform button. As seen in Figure 4, the end product should look like this. You'd select iOS if you wanted to target the iPhone.


The Build Settings dialogue can then be closed or moved out of the way for the time being.

Adding to Your Virtual Reality Project

Figure 3 should still appear in your Unity editor if you look at it. The work area, which we'll name the Scene, is located in the upper centre region of the screen, as indicated by the tab. A sunburst and a camera symbol may be found in the scene area. The camera determines where your VR environment will be viewed. The sunburst is just a source of light that will aid in the visibility of objects. Your resultant application would be like standing in a dark chamber with no windows or light—you wouldn't be able to see anything!


By adding game elements to this scene, you will design own virtual reality universe.


Click the GameObject menu item in the Unity navigation to add a game object. Because you're creating a 3D solution, select the 3D Object sub-menu. This will provide a selection of 3D GameObjects from which you can choose one to add to your project.


3D GameObjects in Unity

Unity 3D GameObjects (Figure 5)


Select the Sphere to keep things simple. As demonstrated in Figure 6, this will add a basic sphere to your picture.


Including a sphere in your virtual environment

Adding a sphere to your virtual environment (Figure 6)


Congratulations! You've just constructed a virtual environment with a sphere in the centre.


The Sphere is also listed in the SampleScene, which can be found in the upper-left corner of the Unity screen. The sphere's properties (settings) may be found in the Inspector dialogue on the right side of the page.


It's likely that you'll want to tweak or shift your sphere. There are a variety of icons in the top left corner of the Unity editor that may be picked to alter your item in the Scene window. The move icon is most likely highlighted by default. The tool list is shown in Figure 7.


Object manipulation tools in Unity

Figure 7: Object manipulation tools in Unity


By using your input device and the arrows in the scene view with the move tool highlighted, you may move the sphere in any of the three axes (such as a mouse). A box may be seen within the sphere if you look attentively. To move the sphere across two axes, click and drag the sides of the box. When you switch to the scale tool, you may stretch or squash the item in any of the three coloured boxes, or you can click and drag the box in the centre to proportionately scale the whole game object.


You'll notice the changes in the Inspector window on the right if you move or scale the item. Figure 6 shows a sphere with a scale of 1,1,1 and a location of 0,0,0. Figure 8 shows that I've scaled the entire sphere by 2 and shifted the item up by 1 unit. (Note that the graphic shows I've increased it by.99 units, or almost one!)


In Unity, a modified sphere

Figure 8: A Unity sphere that has been tweaked.


You may modify an item in the inspector or through the Scene. Changing the values in the inspector offers you more control over the values, but altering in one location will automatically affect the other.


Additional objects can be added to the scene. You may use the hierarchy panel on the left to organise things if you want to. The sphere may be seen listed inside the picture in Figure 8. Additional game objects will be added as you add them. Figure 9 depicts my scene after the addition of three cubes.


Increasing the number of things in a scenario

Figure 9: Increasing the number of things in a scenario


The y position of the second cube, Cube(1), was modified to 2 in the Inspector window, which shifted it above the sphere. The coordinates of the third cube, Cube(2), were modified to x = 2 and z = -2. By choosing the items and reviewing the Inspector values displayed, you may see these values. By clicking on the items in the scene or in the hierarchy list on the left, you may pick them.


Even if this scenario would create a terrible virtual world in general, it is sufficient to acquire a feel for adding things and seeing them in VR. The next stage is to design your virtual environment, whether it's as basic as the one shown in Figure 9 or more complicated.

 
 
 

Recent Posts

See All

Comments


  • Facebook
  • Twitter
  • Instagram

Inner Pieces

Mumbai, India

Office no 2, Ground Floor,
K wing, Sumer Nagar – 2,
Near Kora Kendra Bus Stop,
S.V. Road, Borivali West,
Mumbai, Mahara
shtra 400092

© 2023 by Inner Pieces.

Proudly created with Wix.com

Contact

Ask me anything

Thanks for submitting!

bottom of page