unity38 점프 후 접촉한 발판(플랫폼)이 떨어지고 다시 리스폰되는 발판 구현. How to make Respawn Platforms & Falling Platforms | 유니티 게임 개발 튜토리얼(Unity & C# Script) 캐릭터가 점프해서 발판에 닿으면 그 발판이 잠시 후 떨어지고 다시 발판이 리스폰되는 방법을 알아봅니다. 발판들을 딛고 지나가면 하나씩 떨어지고 떨어진 순서대로 차례로 하나씩 발판들이 리스폰됩니다. [CharacterMove.cs] using System.Collections; using System.Collections.Generic; using UnityEngine; public class CharacterMove : MonoBehaviour { [SerializeField] float speed = 4f, jumpForce = 500f; float moveX; Rigidbody2D rb; void Start() { rb = GetComponent(); } void Update() { Movement(.. 2021. 1. 29. 캐릭터가 점프 후 접촉한 발판(플랫폼) 추락하게 만들기. 플랫폼 떨어뜨리기 구현. How to Make Falling Platforms | 유니티 게임 개발 튜토리얼(Unity & C# Script) 캐릭터가 점프해서 발판에 닿으면 그 발판이 잠시 후 떨어지게 만드는 방법을 알아봅니다. 발판들을 여러개 만들어 계속 점프해서 지나가면 그 발판들이 하나씩 떨어지게 됩니다. 타이밍이 못 맞춰 점프가 늦으면 그 발판과 함께 플레이어가 추락하게 됩니다. [Character.cs] using System.Collections; using System.Collections.Generic; using UnityEngine; public class Character : MonoBehaviour { [SerializeField] float speed = 4f, jumpForce = 500f; float moveX; Rigidbody2D rb; void Start() { rb = GetComponent(); } void.. 2021. 1. 27. 특정 오브젝트에 마우스 오버시 커서 모양 바꾸기How To Change the Cursor Texture when mouse over | OnMouseEnter & OnMouseExit | 유니티 게임 개발 튜토리얼(Unity & C# Script) 평상시 때의 마우스 커서 모양과 특정 오브젝트에 마우스 오버시 변경될 커서를 원하는 형태의 텍스쳐로 바꾸는 방법에 대해 알아봅시다. OnMouseEnter와 OnMouseExit를 이용해 적용해봅니다. | 유니티 게임 개발 튜토리얼(Unity & C# Script) [HandCursor.cs] using System.Collections; using System.Collections.Generic; using UnityEngine; public class HandCursor : MonoBehaviour { [SerializeField] Texture2D cursorArrow; [SerializeField] Texture2D cursorHand; void Start() { Cursor.SetCursor(c.. 2021. 1. 26. 원하는 형태로 커서 모양 바꾸기, 커스텀 커서 | How To Change Mouse Cursor Image | 유니티 게임 개발 튜토리얼(Unity & C# Script) 사용자가 원하는 형태의 이미지로 커서 모양을 바꿔보도록 합니다. [ChangeCursor.cs] using System.Collections; using System.Collections.Generic; using UnityEngine; public class ChangeCursor : MonoBehaviour { [SerializeField] Texture2D cursorImg; // Start is called before the first frame update void Start() { Cursor.SetCursor(cursorImg, Vector2.zero, CursorMode.ForceSoftware); } } 2021. 1. 25. 아이템 줍기(획득, 먹기). 아이템에 접근시 특정키 누르라는 메시지 띄우기. How to text to appear when Pick Up Item | 유니티 게임 개발 튜토리얼(Unity & C# Script) 로봇 캐릭터가 좌우로 이동하여 바닥에 놓여진 무기 아이템에 접근시(Collision) 화면에 "특정키를 누르면 아이템 획득"한다는 메시지가 뜨고 그 특정키를 누르면 아이템이 사라지게 됩니다. [Robot.cs] using System.Collections; using System.Collections.Generic; using UnityEngine; public class Robot : MonoBehaviour { [SerializeField] float speed; float moveX; Rigidbody2D rb; void Start() { rb = GetComponent(); } void Update() { moveX = Input.GetAxis("Horizontal") * speed; rb.vel.. 2021. 1. 24. 왼쪽 Shift키 누르면 달리기 구현. 걷기 & 달리기. How to Character running when hold down Left Shift | 유니티 게임 개발 튜토리얼(Unity & C# Script) 캐릭터를 일반적인 속도로 상하좌우(WSAD)키로 이동시켜보고, 이동하면서 왼쪽 쉬프트키를 동시에 누렀을 때 지정한 속도로 달리기하는 캐릭터를 구현해봅니다. Unity & C# Script [WalkAndRun.cs] using System.Collections; using System.Collections.Generic; using UnityEngine; public class WalkAndRun : MonoBehaviour { float speed, moveX, moveY; [SerializeField] float normalSpeed, runSpeed; void Update() { Movement(); } void Movement() { if (Input.GetKey(KeyCode.LeftShift).. 2021. 1. 23. 코루틴 간단 사용 방법 How To Use Coroutine | 유니티 게임 개발 튜토리얼(Unity & C# Script) 정해진 시간이 지나면 지정한 오브젝트를 사라지도록 코루틴을 이용하여 간단하게 구현해 보도록합니다. IEnumerator에 시간과 사라지는 명령어를 지정하고 StartCoroutine에서 실행을 합니다. [Coroutine.cs] using System.Collections; using System.Collections.Generic; using UnityEngine; public class Coroutine : MonoBehaviour { [SerializeField] GameObject obj; [SerializeField] int hideSeconds = 3; void Start() { StartCoroutine(HideObj()); } IEnumerator HideObj() { yield retur.. 2021. 1. 22. 특정 영역만 보여주는 스프라이트 마스크 사용방법 How To Use Sprite Mask | 유니티 게임 개발 튜토리얼(Unity & C# Script) Sprite Renderer 옵션 중 Mask Interaction이 Visible Outside Mask면 마스크 영역에서 가려지게 되고 Visible Inside Mask면 마스크 영역에 보여지게 됩니다. 이 스프라이트 마스크를 적절하게 사용한다면 아주 다양한 효과를 표현할 수 있습니다. [FollowCursor.cs] using System.Collections; using System.Collections.Generic; using UnityEngine; public class FollowCursor : MonoBehaviour { void Update() { transform.position = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosit.. 2021. 1. 21. 마우스 커서 잠그기와 풀기, 숨기기와 보이기 How to Hide and Lock the Mouse Cursor | 유니티 게임 개발 튜토리얼(Unity & C# Script) 마우스 커서를 특정키를 눌렀을 때 잠그거나 풀고, 숨기거나 보이게 할 수 있는 방법을 알려드립니다. CursorLockMode.Locked을 이용하면 마우스 커서를 게임 중앙 좌표에 고정시키고 마우스 커서가 안보이게 할 수 있고 단순이 화면에서 보이지 않게 하려면 Cursor.visible을 false로 지정하면 됩니다. Cursor.lockState = CursorLockMode.Locked; 마우스 커서를 게임 중앙 좌표에 고정시키고 마우스 커서가 안보임 Cursor.lockState = CursorLockMode.None; 마우스 커서를 게임 중앙 좌표에 고정시키고 마우스 커서가 보임 Cursor.lockState = CursorLockMode.Confined; 마우스 커서를 게임 창 밖으로 이탈 .. 2021. 1. 20. 이전 1 2 3 4 5 다음