사생활 보호 설정
https://gamjia.tistory.com
Updated News
Mini Rooms
답글수 [0]
What Friends Say
한마디로 표현해봐~
1촌평 관리
[Day 18] Suika Game Tutorial 2
GamJia 2024. 11. 24. 21:47
오블완 챌린지 18일차
어제 김장하고 오늘 집에 왔는데
벌써 주말이 다 가버려서
눈물 나는 GamJia 입니다
어제 강의에 이어서Suika Game을 만들어 보겠습니다
일단 과일들이 나타날 때,
사라질 때 Animation이 있으면 좋을거 같아서
과일들에 Animator Component를
추가해주도록 하겠습니다
일단 Appear라는 이름의 Animation을
추가해주고 왼쪽 밑의 Record 버튼을
클릭해주도록 하겠습니다
Record 버튼을 누르면 오브젝트의 변화(위치, 회전, 크기 등)가
자동으로 키프레임(Keyframe)으로 저장된답니다.
https://docs.unity3d.com/Manual/animeditor-AnimatingAGameObject.html
Unity - Manual: Animate a GameObject
Create a new Animation Clip Animate a GameObject There are two methods you can use to animate GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is
docs.unity3d.com
Scale은 0->1.2->0.9->1
Alpha 값은 0->1로 올려줄게요
record 버튼을 눌렀기 때문에
Inspector에서 값을 수정하면
KeyFrame에 바로 반영 됩니다
Animation 설정이 완료 됐다면
Animator에 들어가서 Loop 설정을
해제해주도록 하겠습니다
disappear라는 사라지는
Animation을 하나 생성해주고
Scale은 1->0.7->1.5
Alpha 값은 1->0로 낮춰줄게요
Collider는 혹시 모를 충돌을
방지하기 위해 처음부터 꺼주겠습니다
Appear와 동일하게 Loop 설정을 꺼주고
Trigger Parameter를 하나 생성해
Transition에 연결해주겠습니다
using System.Collections; using System.Collections.Generic; using UnityEngine; namespace SuikaGame { public class Fruit : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } private void OnCollisionEnter2D(Collision2D collision) { // 충돌한 객체에서 Fruit 컴포넌트를 가져옵니다. Fruit otherFruit = collision.gameObject.GetComponent<Fruit>(); if (otherFruit != null) // Fruit 컴포넌트가 있는 경우 { Animator animator = GetComponent<Animator>(); if (animator != null) { animator.SetTrigger("isDisappear"); // Trigger 실행 } } } } }
그리고 전에 미리 만들어둔
Fruits Class를 다음과 같이 수정해주겠습니다
지금은 과일 객체면 종류와 상관 없이
다 사라지는 Animation이 재생되게
설정 되어있습니다
저장 후 실행했더니 과일 구분 없이
부딪히기만 하면 사라지는 모습입니다
내일은 저걸 구분하고 상위 레벨 객체
생성하는 방법을 알려드리겠습니다!
오늘은 여기까지 하고
GitHub에 Commit하는걸로
마무리 하겠습니다!
집에 올 때 오랜만에
도넛을 사먹었더니 배가 안고파서
여태 저녁을 안먹었네요..
저는 이만 밥 먹으러 가겠습니다
감사합니다!!