커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
1-8 빗방울이 땅에 닿아도 점수가 올라가요
undefined주차
북마크
강*경
댓글
10
추천
0
조회수
18
조회수
18
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.



빗방울이 르탄이에게 닿지 않고 땅에 떨어져도 점수가 올라가요

코드 자체에 문제가 있는 건지.. 한 번 봐주시면 좋을 것 같습니다!



스파르타 즉문즉답


using System.Collections;

using System.Collections.Generic;

using System.Drawing;

using UnityEditor.Experimental.GraphView;

using UnityEngine;


public class NewBehaviourScript : MonoBehaviour

{

    float size = 1.0f;

    int score = 1;


    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(5.5f, 6f);

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


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

        if (type == 1)

        {

            size = 0.8f;

            score = 1;

            renderer.color = new UnityEngine.Color(100 / 255f, 100 / 255f, 1f, 1f);

        }

        else if (type == 2)

        {

            size = 1f;

            score = 2;

            renderer.color = new UnityEngine.Color(130 / 255f, 130 / 255f, 1f, 1f);

        }

        else if (type == 3)

        {

            size = 1.2f;

            score = 3;

            renderer.color = new UnityEngine.Color(150 / 255f, 150 / 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);

        }


        if (collision.gameObject.CompareTag("Player"));

        {

            Gamemanager.Instance.AddScore(score);

            Destroy(this.gameObject);

        }

    }

}


스파르타 즉문즉답






취소
 공유
취소
댓글 0
댓글 알림
나의얼굴