본문 바로가기

분류 전체보기183

23/08/27 [주말과제] HeroShooter Stage1 미완 Player using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; public class Player : MonoBehaviour { private Transform playerTrans; public float moveSpeed = 5f; private Animator anim; public float turnSpeed = 80f; private Rigidbody rBody; [SerializeField] private float radius = 1.0f; [SerializeField] private float rayOffsetY = 0.5f; //Ray 오프셋 [SerializeF.. 2023. 8. 27.
23/08/24 HeroShooter 사정거리 안에 몬스터 감지 사정거리 안에 가장 가까운 몬스터 인지 - layer 설정하기 - collider 없으면 게임오브젝트에 달아주기 - collider 배열 만들기 - monster collider들 검색하기 - 순회하면서 player collider와 monster collider 사이 거리 측정 - 둘 사이의 거리 어딘가에 저장 (사전 등..) - 가장 가까운 오브젝트 구하기 - 둘 사이의 방향 구하기 - 해당 게임오브젝트에게 ray 쏘기 2023. 8. 24.
23/08/24 SpaceShooter 몬스터 공격 스크립트 MonsterController using System.Collections; using System.Collections.Generic; using Unity.VisualScripting.Antlr3.Runtime.Misc; using UnityEngine; using UnityEngine.AI; public class MonsterController : MonoBehaviour { //상태 정의 public enum eState { IDLE, TRACE, ATTACK, DIE } //몬스터의 현재 상태 저장하는 변수 public eState state; //공격사거리 변수 정의 [SerializeField] private float attackRange = 2.0f; //추적사거리 변수 정의 [Ser.. 2023. 8. 24.
23/08/23 HeroShooter 포탈 닿으면 FadeOut Main using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GameMain1 : MonoBehaviour { [SerializeField] private Player player; [SerializeField] private Joystick joystick; [SerializeField] private Portal portal; [SerializeField] private Door door; [SerializeField] private GameObject portal2; [SerializeField] private Image dim; // Start i.. 2023. 8. 23.
23/08/22 HeroShooter 이동하기 Main using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameMain1 : MonoBehaviour { [SerializeField] private PlayerController playerController; [SerializeField] private Joystick joystick; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { //조이스틱 방향 가져오기 float h = this.joystick.Horizontal; f.. 2023. 8. 22.
23/08/21 Player 목표지점까지 이동 후 회전 (Lerp,Quaternion) using System.Collections; using System.Collections.Generic; using UnityEngine; public class TestPlayer : MonoBehaviour { [SerializeField] private Transform eye; private Vector3 targetPosition; private Quaternion trot; private void Start() { MoveForward(); //CoMoveForward(); } public void MoveForward() { Ray ray = new Ray(this.eye.position, this.transform.forward); Debug.DrawRay(ray.origin, ray.d.. 2023. 8. 21.