깃발타면 내려오기 400점 추가
성에 도착하면 시간 0으로 줄어들기, 점수 비례해서 증가하기
벽돌깨면 아이템 생성
깃발타면 내려오는거 구현하려고 isTriggerEnter를 수정한 이후로 갑자기 마리오가 움직이질 않음. 원래대로 변경했는데도 안움직임 ..
계속 bounds가 변경되고 마리오의 위치는 변경되지 않음
collider도 꺼보고 의심되는 코드부분에 주석걸어가면서 확인했는데 해결되지 않고 있음
오류가 뜨지도 않음..
=> 애니메이터 끄니까 움직임 ... 잘못만들었나.. 어젠 잘됐었는데 어이없다 ..
점프쪽에서 문제가 있을거같아 코드를 다 지우고 연결을 걷는 애니메이션만 남기고 끊었음 -> 그래도 움직이지 않음-> 걷는 애니메이션 빼고 아예 지워버림 => 잘 움직임
marioFlag 에서 문제가 있는거같아서 jump는 다시 추가해봄 => 잘됨
결론: 새로 만들었던 marioFlag animation에 문제가 있었나봄
뭐가 문제지 ^^.. 애니메이터에 존재한다는 이유만으로도 안움직이다니 .. 아 씬이 다른데 .. 다른씬 위치로 설정을 해서 그런가
일단은 애니메이션 적용하지 말고, 깃발에 도착하면 점수가 400점 추가되는거만 해야겠다
private void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "coin")
{
Destroy(other.gameObject);
this.uiDirector.IncreaseScore(50);
this.uiDirector.IncreaseCoin();
}
if (other.gameObject.tag == "flag")
{
this.uiDirector.IncreaseScore(400);
}
this.uiDirector.UpdateUI();
}
이거만 추가
성에 도착하면 시간에 비례해서 점수 증가
벽돌깨면 아이템 나오기
using UnityEngine;
using static UnityEditor.Progress;
public class BrickController : MonoBehaviour
{
private Animator anim;
[SerializeField]
private ItemGenerator.eItemType rewardItemType;
[SerializeField]
private Main main;
[SerializeField]
private GameObject coinPrefab;
//public System.Action<ItemGenerator.eItemType> onChanged;
// Start is called before the first frame update
void Start()
{
this.anim = this.GetComponent<Animator>();
}
// Update is called once per frame
public void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "mario")
{
this.anim.SetBool("isCrashed", true);
Instantiate(coinPrefab, new Vector3(transform.position.x,transform.position.y+1.5f,transform.position.z),transform.rotation);
}
}
}
=> 충돌할때마다 생성
private bool isCrashed = false;
if (isCrashed == false)
{
Instantiate(coinPrefab, new Vector3(transform.position.x, transform.position.y + 1.5f, transform.position.z), transform.rotation);
isCrashed = true;
}
=> 한번만 생성됨
itemGenerator로 만드려고 했는데 넘 어려워서 그냥 코인나오는 블록, 버섯나오는 블록 따로 만들었다.
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using static UnityEditor.Progress;
public class BrickMushroomController : MonoBehaviour
{
private Animator anim;
[SerializeField]
private GameObject mushroomPrefab;
private bool isCrashed = false;
//public System.Action<ItemGenerator.eItemType> onChanged;
// Start is called before the first frame update
void Start()
{
this.anim = this.GetComponent<Animator>();
}
// Update is called once per frame
public void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "mario")
{
this.anim.SetBool("isCrashed", true);
if (isCrashed == false)
{
Instantiate(mushroomPrefab, new Vector3(transform.position.x, transform.position.y + 0.5f, transform.position.z), transform.rotation);
isCrashed = true;
}
}
}
}
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using static UnityEditor.Progress;
public class BrickCoinController : MonoBehaviour
{
private Animator anim;
[SerializeField]
private GameObject coinPrefab;
private bool isCrashed = false;
//public System.Action<ItemGenerator.eItemType> onChanged;
// Start is called before the first frame update
void Start()
{
this.anim = this.GetComponent<Animator>();
}
// Update is called once per frame
public void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "mario")
{
this.anim.SetBool("isCrashed", true);
if (isCrashed == false)
{
Instantiate(coinPrefab, new Vector3(transform.position.x, transform.position.y + 1.2f, transform.position.z), transform.rotation);
isCrashed = true;
}
}
}
}
https://nanalistudios.tistory.com/11 속도 느려지기 블로그 참고
시간 비례해서 점수 증가 감 안잡힘
일단 UI 유지하는거 다시 도전
'2D 콘텐츠 제작 개발일지 (mario)' 카테고리의 다른 글
마리오 개발 7일차 (2) | 2023.09.19 |
---|---|
마리오 개발 6일차 (0) | 2023.09.18 |
마리오개발 4일차 (0) | 2023.09.16 |
마리오 개발 3일차(포탈이동/UI) (0) | 2023.09.15 |
마리오개발 2일차(벽돌 깨기) (0) | 2023.09.14 |