Unity/Unity Study

[Unity] 2024.12.30 오늘 나의 공부는

JEE_YA 2024. 12. 30. 17:56
public class Rain : MonoBehaviour
{
    // Start is called before the first frame update
    // 스타트는 딱 한번만 호출되는 자리 
    void Start()
    {

    }

    // Update is called once per frame
    // 업데이트는 반복되어 호출되는 자리 
    void Update()
    {

    }

    // 충돌현상은 OnCollisionEnter2D로 입력
    private void OnCollisionEnter2D(Collision2D collision)
    {

    }

}

저번 강의에서도 설명해주셨던 거지만 다시한번 복습을 위해 정리

public class Rain : MonoBehaviour
{
    float size = 1.0f;
    int score = 1;
    //스코어는 정수가 되어야 하기 때문에 int 사용

    SpriteRenderer renderer

    // Start is called before the first frame update
    void Start()
    {

        renderer = GetComponent<SpriteRenderer>();

        float x = Random.Range(-2.4f, 2.4f);
        float y = Random.Range(3.0f, 5.0f);
        //x, y값에 대해 랜덤으로 지정하게 해주는 코드

        transform.position = new Vector3(x, y, 0);

        int type = Random.Range(1, 4);

        if (type == 1)
        {
            size = 0.8f;
            score = 1;
            renderer.color = new Color(100 / 255f, 100 / 255f, 1f, 1f);

        }

        else if (type == 2)
        {
            size = 1.0f;
            score = 2;
            renderer.color = new Color(130 / 255f, 130 / 255f, 1f, 1f);
        }

        else if (type == 3)
        {
            size = 1.2f;
            score = 3;
            renderer.color = new Color(130 / 255f, 130 / 255f, 1f, 1f);
        }

        transform.localScale = new Vector3(size, size, 0);
        }

    // Update is called once per frame
    void Update()
    {

    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        if(collision.gameObject.CompareTag("Ground"))
        {
            Destroy(this.gameObject);
            //레인과 충돌(collision)한 물체(gameObject=Graound)를 파괴(Destroy)시켜라
        }
    }
  • input : 외부장치
  • ! : 반대를 사용할때
  • 그 외는 주석을 이용하였음
  • 오타 다시한번 꼭 확인하기 (튜터님께 오류에 대해 여쭤봤다가 간단한 오타로 인한 오류였단걸 알게되었을 땐 부끄러웠다..)

 

강의에 집중하면서 코드에 대해 이해와 유티니에 대한 이해는 하려고 열심히 노력하였는데

오늘의 공부에 제일 어려웠던 점은 Mac OS다.

윈도우만 사용하다 맥 사용하려고 하니 뭐가 뭔지, 한영 변환과 단축키에 대해 혼동도 많이 오고 오류도 많이 나고 해서 세팅만 새벽부터 낑낑대면서 4시간 가까이 한것 같다...

얼른 맥에 적응하고 빠르게 진도 나가고 싶다!