응용프로그램 146

Unity - 스폰 시스템 만들기

스폰시스템 만들기 출처 : Sebastian Lague LivingEntity에서 아래의 코드를 잘 삽입~ public event System.Action OnDeath; if (OnDeath != null) { OnDeath(); //죽을때마다. 이벤트가 들어감 } Spawner.cs using UnityEngine; using System.Collections; public class Spawner : MonoBehaviour { public Wave[] waves; public Enemy enemy; int enemiesRemainingToSpawn; int enemiesRemainingAlive; float nextSpawnTime; Wave currentWave; int currentWaveNu..

Unity - 데미지 시스템

데미지 시스템 출처 : Sebastian Lague 상속과 오버라이드 virtual, override base.start(); 변수의 접근제한 protected interface IDamageable.cs using UnityEngine; public interface IDamageable { void TakeHit(float damage, RaycastHit hit); } LivingEntity.cs using UnityEngine; using System.Collections; public class LivingEntity : MonoBehaviour, IDamageable { public float startingHealth; protected float health; protected bool d..

Unity - 충돌감지관련

충돌감지관련 출처 : Sebastian Lague의 동영상 강의 using UnityEngine; using System.Collections; public class Projectile : MonoBehaviour { public LayerMask collisionMask; float speed = 10; public void SetSpeed(float newSpeed) { speed = newSpeed; } void Update () { float moveDistance = speed * Time.deltaTime; CheckCollisioins(moveDistance); transform.Translate(Vector3.forward * Time.deltaTime * speed); } void Ch..

유니티 DB 사용하기

유니티 DB관련 참고자료 SQLite 소개 http://www.csharpstudy.com/Practical/Prac-sqlite.aspx c#으로 SQLite 연결하기 http://answers.unity3d.com/questions/743400/database-sqlite-setup-for-unity.htmlhttp://nsinc.tistory.com/127 보조도구 http://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki 예제 http://forum.unity3d.com/threads/tutorial-how-to-integrate-sqlite-in-c.192282/ http://www.codeproject.com/Articles/6343/..

Unity - 3D게임만들기(Ray로 오브젝트 방향전환)

Ray로 오브젝트 방향전환하기 오브젝트를 생성한뒤 소스코드를 붙이고 아래의 코드를 실행하면 됩니다. Player.cs using UnityEngine; using System.Collections; [RequireComponent (typeof(PlayerController))] public class Player : MonoBehaviour { public float moveSpeed = 5; Camera viewCamera; PlayerController controller; void Start () { controller = GetComponent(); viewCamera = Camera.main; } void Update () { Vector3 moveInput = new Vector3(Input..

Unity - 이동 및 회전

알면 좋은 소스 Input.GetAxis ("받아들일 행동") GetAxis의 이동을 부드럽게~ 받아들임 Input.GetAxisRaw ("받아들일 행동") GetAxis의 이동을 즉시 받아들임 transform.LookAt(point); point의 방향으로 바라본다. imgLoading.rectTransform.Rotate(new Vector3(0, 0, -2)); z방향으로 -2만큼 회전시킴. 회전참조 캐릭터 움직이는 예지 Player.cs using UnityEngine; using System.Collections; [RequireComponent (typeof (PlayerController))] public class Player : MonoBehaviour { public float mov..