Download presentation
Presentation is loading. Please wait.
1
First Person Shooter Project
Unity3D Tutorial First Person Shooter Project
2
2D Game 변환 2D Space Shooter 이용하여 3D 게임으로 변환 Main Camera
Position: 0,0,5; Rotation: 0,0,0; Projection: Perspective Background Position: 0,0,16; Rotation: 0,0,0; Scale: 30,30,0;
3
FPS Project First Person Shooter Project 게임 환경 제작
Game Object와 Material를 이용한 자체 제작 Asset Store를 이용한 게임환경 제작 Character Controller 적용 Script를 이용한 Shooting 게임 GUI 구성
4
Game World 제작 준비 Game World 제작 File Menu Open Project “FPS3D”
Download 3DGameTemplate Asset Import Package Characters & ParticleSystems Open “1_Start.unity” Import Packages > Characters Import Packages > ParticleSystems
5
Asset Store에서 Asset 가져오기
Select Window Asset Store Select Categories Texture & Materials Metal Select Top Free “Yughues Free Metal materials” Download & Import
6
Character Controller Character Controller 사용 Delete Camera
1인칭 컨트롤러 추가 방법 Standard Assets > Characters > FirstPersonCharacter 선택 프로젝트 뷰에서 Prefabs> “FPSController” 드래그하여 씬뷰에 가져다 놓음 (캡슐 생김) Rename “Player” & Select Tag “Player” FirstPersonCharacter Add Component “GUI Layer” 2_Add_FirstPersonCharacter.unity 기존 Camera 제거
7
Shooting using C# Script
Create Empty Object “Launcher” Drag the Launcher object onto “FirstPersonCharacter” object that belongs to the FPS Controller in the Hierarchy panel Create Bullets Using Prefabs Create Bullets Create > 3D Object > Sphere “MyBullet” scale 0.2 Attach a rigid body component to the “MyBullet” Component > Physics > RigidBody Create “Prefabs” Create New Prefab “MyBullet” drag and drop the bullet game object from the Hierarchy window onto the bullet prefab in the Project window Delete the bullet game object in the Hierarchy window.
8
Shooting using C# Script
Launcher로부터 총알(Bullet) 발사 Select “Launcher” Object Create C# Script “createMyBullet” Add Component > New script Open MonoDevelop “Bullet” is assigned to the prefab Bullet variable in the script using UnityEngine; using System.Collections; public class CreateMyBullet : MonoBehaviour { public Rigidbody prefabBullet; public float bulletForce = f; void Update() { if (Input.GetButtonDown("Fire1")) { // 총알 오브젝트(InstanceBullet) 생성 Rigidbody instanceBullet = Instantiate(prefabBullet, transform.position, transform.rotation) as Rigidbody; instanceBullet.AddForce(transform.forward * bulletForce); // 총알 오브젝트 앞으로 발사하는 힘 추가 Physics.IgnoreCollision ( instanceBullet.GetComponent<Collider>(),transform.root.GetComponent<Collider>() ); // Player의 Collider 와의 충돌 무시 } 3_Launcher.unity
9
Explosion Add Explosion Effect 충돌 파티클 생성 Select MyBullet
Add C# Script “MyProjectile” & Open MonoDevelop Import Standard Assets ParticleSystems Select “Explosion” prefab Drag & Drop “Explosion” variable using UnityEngine; using System.Collections; public class MyProjectile : MonoBehaviour { public GameObject explosion; void OnCollisionEnter( Collision collision) { ContactPoint contact = collision.contacts[0]; // 총알과의 충돌지점 Quaternion rotation = Quaternion.FromToRotation( Vector3.up, contact.normal ); // 충돌지점의 방향 GameObject instantiatedExplosion = Instantiate( explosion, contact.point, rotation ) as GameObject; // 충돌후 폭파(instantiateExplosion) 오브젝트 생성 Destroy(gameObject); // 총알 오브젝트 제거 }
10
Explosion Destroy explosion prefab 충돌 파티클 제거 Select “Explosion” prefab
Add C# Script “ExplosionRemover” & Open MonoDevelop using UnityEngine; using System.Collections; public class MyExplosionRemover : MonoBehaviour { public float explosionTime = 1.0f; void Start () { // 폭파 파티클 1초후 제거 Destroy( gameObject, explosionTime ); } 4_Bullet_Explosion.unity
11
Make Enemy Objects 총알과의 충돌 오브젝트 (Box) 생성
Create Game Object Cube “MyBox” Attach a rigid body component to the “MyBox” Add Script “Mover” & “Random Rotator” Create Prefab “Box” Select Box in Hierarchy View Drag & Drop the box in Project View
12
Make Enemy Objects Box 오브젝트 폭파
5_BoxCollsion.unity Select “MyBox”, Add Script “BoxCollsion” Select “explosion_player” prefab using UnityEngine; using System.Collections; public class BoxCollsion : MonoBehaviour { public GameObject explosion; void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Floor") { return; // Floor 와의 충돌은 무시 } if (collision.gameObject.tag == "Player") { Instantiate (explosion, transform.position, transform.rotation); Destroy (gameObject); else { Destory (collsion.gameObject);
13
Add Sound Import Sound File Shooting Sound Explosion Sound
총알 발사 및 폭파 사운드 추가 Import Sound File Asset store Catagories Audio Sound FX Weapons Select Top Free Futuristic weapon set Download & Import Shooting Sound Select “Bullet” in Project View Add Component Audio Audio Source Select Audio Clip “weapon_player” & Check Play On Awake Explosion Sound Select “Explosion” prefab in Project View Select Audio Clip “explosion_enemy” & Check Play On Awake
14
Score & Health Displaying GUI
Using 2DShootingGame “DisplayText”, Check “DisplayText” Select “Player” FirstPersonCharacter Add Component “GUI Layer” Using 2DShootingGame “GameController” & Check it using UnityEngine; using System.Collections; public class GameController : MonoBehaviour { public GameObject hazard; 중략 public int health=100; void Start () { UpdateHealth (); } public void MinusHealth(int newHealthValue) { health -= newHealthValue; void UpdateHealth() { restartText.text = "Health: " + health;
15
Score & Health Update score value
Select Prefab “Bullet”, Change Script “Projectile” using UnityEngine; using System.Collections; public class Projectile : MonoBehaviour { public GameObject explosion; public int score=10; private GameController gameController; void Start() { GameObject gameControllerObject = GameObject.FindWithTag ("GameController"); if(gameControllerObject != null) { gameController = gameControllerObject.GetComponent<GameController>(); } if(gameController == null) { Debug.Log("Cannot find 'GameController' script"); void OnCollisionEnter(Collision collision) { 중략 if (collision.gameObject.tag == "Floor") { Destroy (gameObject); return; } else { gameController.AddScore (score); Destroy (collision.gameObject); Destroy (gameObject);
16
Score & Health Update health value
Select Prefab “Box”, Change Script “BoxCollsion” using UnityEngine; using System.Collections; public class BoxCollsion : MonoBehaviour { public GameObject explosion; public int healthValue=10; private GameController gameController; void Start() { GameObject gameControllerObject = GameObject.FindWithTag ("GameController"); if(gameControllerObject != null) { gameController = gameControllerObject.GetComponent<GameController>(); } if(gameController == null) { Debug.Log("Cannot find 'GameController' script"); void OnCollisionEnter(Collision collision) { 중략 if (collision.gameObject.tag == "Player") { Instantiate (explosion, transform.position, transform.rotation); gameController.MinusHealth (healthValue); Destroy (gameObject); if (gameController.health == 0) gameController.GameOver ();
17
FPS Demo Play It!!! Play Other!!!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.