Skip to content

GPROWIRELESS/CS-8395-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reproduce the project

If you want to reproduce the project, download the Assets file. You need to create a Unity3D project(3D Sample Scene(URP)), copy the Assets and override it. Then go to unity assets store, download and import the following assets:

https://assetstore.unity.com/packages/3d/environments/landscapes/lowpoly-style-free-rocks-and-plants-145133 https://assetstore.unity.com/packages/3d/props/exterior/stones-40329 https://assetstore.unity.com/packages/3d/props/exterior/cartoon-low-poly-tree-211305 https://assetstore.unity.com/packages/audio/sound-fx/grenade-sound-fx-147490 https://assetstore.unity.com/packages/3d/vehicles/land/cartoon-tank-free-165189 https://assetstore.unity.com/packages/tools/input-management/joystick-pack-107631 https://assetstore.unity.com/packages/2d/textures-materials/floors/outdoor-ground-textures-12555 https://assetstore.unity.com/packages/vfx/particles/war-fx-5669

Part1:

Description:

This project is a shooting game in augmented reality. In this game, the app will detect specific images and show the game scene. Users can control a little in the scene and shoot the enemy tank and other destructible objects. Users can use two joysticks to control the tank and one button to fire the shell. One joystick controls the tank movement and rotation. The other joystick controls the turret rotation. The enemy tank will automatically aim at the user's tank and fire. Every tank has 100 Hp. Enemy tank will move randomly to avoid user's firepower.

Project proposal:

This project is implemented by Unity3D with AR Foundation/AR Core. The app will be able to install and run on an android device. It also requires this device to support 'Google Play Service for AR'.

Idea:

I love playing tank games such as 'World of Tanks' or 'War Thunder'. However, none of them are AR games. So I try to build my own. It will be quite interesting to control a augmented reality tank and destroy targets.

Tools and goals:

Goals:

I plan to build a game with control UI and cross-hair UI. The controller of this game will be two joystick. One control the direction, rotation and movement of the tank. The other one control the turret rotation. There will be a button to control the cannon to fire shells.

Tools:

I plan to build this game with Unity3D and vuforia. However, after I saw the API of the vuforia, I thought that would be hard for me to achieve the goal. So I switch to AR Foundation/AR Core. In AR Core, there are libraries that support AR image tracking. It also supports me to use the direction and rotation of the camera as the target point. There is a Raycast function. It can emit a beam and detect what virtual game object it hit. That hit point will also be the target point of the tank.

Part2:

Milestone:

MileStone video

https://youtu.be/Ttn59bFZL0M

destory object test

milestone1.mp4

image tracking test

milestone2.mp4

Here is the milestone video. For now, I have added the scene in the game with the tank and plane. I add a button to destroy and add objects in the scene. It is done by the Raycast of the AR camera. In the video, the ray hit the game object's box-collider. I wrote a C# script for AR camera, when the beam emitted from the camera hits the coke, the coke will be destroyed. However, in the video, the beam hit the box-collider of the tank and can't reach coke's collider.

Goals not yet completed:

Controller of the tank. Enemy tank. AR image tracking.

When I put the test scene into the AR image tracking manager, all the input buttons will not work if the scene is generated by this manager, which means the user can't control anything. However, everything works well without the image tracking manager.

Part3:

Final version of the project:

The issue in the mile stone has been fixed. It was caused by the prefab in the Unity3D. The prefab will not save any reference for scripts so the UI button will not be called when the scene is generated. The way I solve this issue is by putting everything referenced in the same prefab. [picture of prefab] The AR image tracking manager will generate the whole prefab when it detects the target image. All the UI are included in this prefab, so UI will show only when target image appears.

Scripts for this app.

Control_target.cs:

This script connects the joystick with the cross-hair in the scene, so users can control the cross-hair.

Control_turret.cs:

This script will get the position of the cross-hair and let the turret keep aiming at the cross-hair.

Destroy_coke.cs:

This script is used for every destructible object. It use 'OnCollisionEnter' function to detect what object hit the collision. If the object's tag is "shell“, the game object with this script will destroy itself.

Enemy_fire_shell.cs:

This script controls the fire rate of enemy tank. Enemy tank will keep firing on user's tank in a constant fire rate.

Enemy_tank_move.cs:

This script manages enemy tank movements. Enemy tank will move randomly to avoid user's shells. It will generate a new target position in several seconds.

Fire_shell.cs:

This script generates the shells when users click the fire button. It will create shells, firing effects, and sound effects at the muzzle.

My_health_point.cs:

This script will count how many hp every tank left. The initial hp is 100. Every time the tank is hit by a shell, the hp will reduce 1.

Player_controller_newjoystick.cs:

This script connects the joystick with the tank. Users can control the tank to move and rotate.

Shell_movement.cs:

This script controls the shell speed and lifetime. Every shell will be destroyed after 7 seconds.

Deliverable Instructions:

To play the game, download and print the target image, then install the apk on any Android device. Reminder, this device needs to support Google play service for AR. You can install this service in Google app store. After installation, open the app, and the game will start after it detect the target image.

Final version Demo video:

Edited

Final_demo.mp4

Full version

https://youtu.be/1YDOr9SPHcg

Download apk and target image:

apk

https://vanderbilt.box.com/s/lekx3z340o5ecs4ra5m8xmpg4q4rppvk

target image

Crewfront

Limitations:

  1. There is no menu to start or exit the game.
  2. No reset button in the game. If users want to restart, they need to close it and open the app again.
  3. Since AR image tracking manager requires input reference as prefab, I put all most every game objects, UI in the same prefab. I believe that's not the original intention of the prefab. It also causes some issues in the game. It will be difficult to destroy or control a game object if it is not in the prefab. For example, if I want to do collision detection between game objects in the prefab and game objects in the scene, it will be very difficult. The game object in the scene will not be able to detect the object in the prefab by using Gameobject.find('objectname') or Gameobject.FindGameObjectwithTag(‘Tagname’). This issue happened with the shells. I solved it in a tricky way. I give every game object in the prefab with several tags. If the game object in the prefab is hit by another object with those tags, nothing will happen. If the game object in the prefab is hit by another object with no tags, this game object will be destroyed.

Reference:

[1]Youtube.com. 2020. Score Unity 2d (for beginners). [online] Available at: https://www.youtube.com/watch?v=cOW_T3i4_kk&ab_channel=DamzGames [Accessed 28 April 2022].

[2] Answers.unity.com. 2017. GameObject.Find() not working when connected to prefab - Unity Answers. [online] Available at: https://answers.unity.com/questions/1390110/gameobjectfind-not-working-when-connected-to-prefa.html [Accessed 28 April 2022].

[3] Answers.unity.com. 2014. How to find a prefab via script at RunTime? - Unity Answers. [online] Available at: https://answers.unity.com/questions/674127/how-to-find-a-prefab-via-script.html [Accessed 28 April 2022].

[4] Technologies, U., 2021. Unity - Scripting API: Resources.Load. [online] Docs.unity3d.com. Available at: https://docs.unity3d.com/ScriptReference/Resources.Load.html [Accessed 28 April 2022].

[5] Technologies, U., 2021. Unity - Manual: Instance overrides. [online] Docs.unity3d.com. Available at: https://docs.unity3d.com/2021.3/Documentation/Manual/PrefabInstanceOverrides.html [Accessed 28 April 2022].

[6] Google Codelabs. n.d. Create an AR game using Unity's AR Foundation | Google Codelabs. [online] Available at: https://codelabs.developers.google.com/arcore-unity-ar-foundation#1 [Accessed 28 April 2022].

[7] Youtube.com. 2021. How to Create Mobile Joystick in Unity 3D | Unity, Joystick, Tutorial, 2021. [online] Available at: https://www.youtube.com/watch?v=7bQqpTkZTkk&ab_channel=Atlass [Accessed 28 April 2022].

[8] Docs.unity3d.com. 2021. Messages | Android Logcat | 1.3.2. [online] Available at: https://docs.unity3d.com/Packages/[email protected]/manual/messages.html [Accessed 28 April 2022].

[9] Technologies, U., 2021. Unity - Manual: Debugging on an Android device. [online] Docs.unity3d.com. Available at: https://docs.unity3d.com/2021.2/Documentation/Manual/android-debugging-on-an-android-device.html [Accessed 28 April 2022].

[10] Technologies, U., 2021. Unity - Manual: Character Controller. [online] Docs.unity3d.com. Available at: https://docs.unity3d.com/2018.4/Documentation/Manual/class-CharacterController.html [Accessed 28 April 2022].

[11] Youtube.com. 2021. How to Move Characters in Unity 3D: Built-In Character Controller Explained [#1]. [online] Available at: https://www.youtube.com/watch?v=UUJMGQTT5ts&ab_channel=iHeartGameDev [Accessed 28 April 2022].

[12] Youtube.com. 2021. Unity C# : Character Controller - part 1.. [online] Available at: https://www.youtube.com/watch?v=dQCMmzQcLIc&ab_channel=aboutgamemaking [Accessed 28 April 2022].

[13] Youtube.com. 2021. Unity C# : Virtual Joystick and Character Move. [online] Available at: https://www.youtube.com/watch?v=9gOF_plwd1g [Accessed 28 April 2022].

[14] Youtube.com. 2020. 6 Ways to move object in Unity [Tutorial]. [online] Available at: https://www.youtube.com/watch?v=-thhMXmTM7Q&ab_channel=FeriFm [Accessed 28 April 2022].

[15] Youtube.com. 2018. Augmented Reality (ARKit) Tutorial - Create a shooting game in AR. [online] Available at: https://www.youtube.com/watch?v=T2_k5NlPjtE&list=LL&index=17&ab_channel=ParthAnand [Accessed 28 April 2022].

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published