쾌락없는 책임 (공부)/Unity
-
[유니티 2D 스터디] 캐릭터 이동, 벽 충돌처리쾌락없는 책임 (공부)/Unity 2021. 3. 11. 21:29
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMove : MonoBehaviour{ Rigidbody2D rigid; SpriteRenderer spriteRenderer; Animator anim; public float maxSpeed; public float jumpPower; public int jumpCount = 0; public int maxJumpCount = 2; // 방향을 가져오기 위한 변수 Vector3 dirVec; // 레이로 스캔하는 물체 받아오는 변수 GameObject scanObject; void Awake() { rigid = GetCompo..
-
유니티 - 플레이어에게 총을 쏘는 적쾌락없는 책임 (공부)/Unity 2021. 1. 15. 22:56
소스코드 총을 쏘는 오브젝트 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Enemyshooting : MonoBehaviour { public GameObject bullet; void Start(){ StartCoroutine(Bullet()); } IEnumerator Bullet(){ Instantiate(bullet, transform.position, transform.rotation); yield return new WaitForSeconds(3.0f); StartCoroutine(Bullet()); } } 총알의 스크립트 using System.Collections; usi..
-
유니티 - 플레이어 슬라이딩 구현쾌락없는 책임 (공부)/Unity 2021. 1. 4. 21:49
// Sliding if (isGround == true && Input.GetKeyDown(KeyCode.LeftShift) && canSlide == true) { animator.SetBool("isSliding", true); canSlide = false; maxSpeed *= 2f; // Speed up gameObject.layer = 12; // become invincible Invoke("slidingFalse", 0.5f); // todo : invoke의 시간을 변수로 변경하자 Invoke("TFslide", 1f); // 1f is delay time } //Sliding void slidingFalse() { maxSpeed = maxSpeed/2.0f; animator.SetB..
-
유니티 - 보스몬스터 패턴 1 : 플레이어 감지 후 공격쾌락없는 책임 (공부)/Unity 2021. 1. 3. 15:57
- 보스 몬스터의 하위 오브젝트로 빈 오브젝트가 있음 - 이 빈 오브젝트에 공격 코드가 달려있으며 OnTriggerStay를 사용하기 위해 tirgger로 만듬 - 소환되는 경고창과 공격(사진에서 몬스터)에 Destroy하는 스크립트가 있음 - 이건 프리팹으로 미리 만들어 둔 것 using System.Collections; using System.Collections.Generic; using UnityEngine; public class BossMonsterPattern : MonoBehaviour { private bool isAttacking = false; Vector3 playerPos; Vector3 whereToAtk; public GameObject warning; public GameO..
-
유니티 UI에 변수 표시쾌락없는 책임 (공부)/Unity 2020. 12. 28. 17:36
1. 표시하고자 하는 변수가 있는 스크립트에 using UnityEngine.UI; 추가 2. 텍스트의 경우 public Text (변수명)을 한 뒤 인스펙터 창에서 만들어둔 ui 텍스트를 하이어라키 창에서 가져온다 3. 그럼 반영이 아주 잘 된다 끝 + 지금의 경우 저 플레이어의 재화를 전역으로하지 않았기에 해당 스크립트에서 불러와야 한다는 불편함이 있다. -> 다음 프로젝트를 만들땐 이런 스탯?들을 한곳에서 관리할 수 있게끔 만들어야 겠다. 2020.12.28 작성
-
유니티2D 다운점프/아래점프 플랫폼 구현쾌락없는 책임 (공부)/Unity 2020. 12. 23. 11:23
거지같은 맥북의 녹화기능 //JUMP isGround = Physics2D.OverlapCircle(pos.position, checkRadius, islayer); if (Input.GetKeyDown(KeyCode.Space) && jumpCount > 0 && !Input.GetButton("Vertical")) { rigid.velocity = Vector2.up * jumpPower; } if (Input.GetKeyUp(KeyCode.Space)) { jumpCount--; } if (isGround) { jumpCount = maxJump; } //DownJump if (Input.GetKeyDown(KeyCode.Space) && Input.GetButton("Vertical")){ Deb..
-
[유니티] 플레이어 능력치 버프/ui표현쾌락없는 책임 (공부)/Unity 2020. 12. 1. 22:10
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class slotItemExample : MonoBehaviour { public float buffTime = 10f; //버프가 지속되는 시간 float curTime; public Image icon; void Start(){ } void Awake(){ icon = GetComponent(); icon.fillAmount = 1; curTime = buffTime; } void Update() { if(Input.inputString == (transform.parent.GetComponent().num ..
-
유니티에 VS code 사용법 (in Mac)쾌락없는 책임 (공부)/Unity 2020. 11. 30. 22:53
youtu.be/btga03_gGfw 위 외국분 영상 보니 한번에 되었다. 단 다른게 하나 있었는데 vs code의 extension에서 c#을 버전을 좀 낮은걸로 받았다(1.22) 버전 업데이트를 하니 바로 자동완성 안되는거 보면 버전의 문제인듯 하다. cafe.naver.com/unityhub/109218 VSCode (Visual Studio Code) 자동 완성이 안 될 때 참조 링크 : https://forum.unity.com/threads/cant-get-vscode-to-work-properly-with-unity.538224/안녕하세요,... cafe.naver.com 원인모를 문제로 다시 자동완성이 안되길레 또 헤매다가 위 글을 보고 구원받았다 2020.11.29 작성 2021.01.0..