
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
int score;로 수정하였습니다.
작동이 안되는데 잘 모르겠습니다 ㅜㅜ..
전체 화면 캡처


한번 챗지피티에 검색해보았는데 score가 사용되고 있지 않다는 것은 이해했는데 왜 작동이 안되는지는 모르겠습니다.
작성한 코드 및 에러 메세지
[입력한 스크립트]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rain : MonoBehaviour
{
// Start is called before the first frame update
float size = 1.0f;
int score; // 말씀하신대로 수정한 부분입니다.
SpriteRenderer renderer;
void Start()
{
renderer = GetComponent<SpriteRenderer>();
float x = Random.Range(-2.4f, 2.4f);
float y = Random.Range(3.0f, 5.0f);
transform.position = new Vector3(x, y, 0);
int type = Random.Range(1, 4);// 3개까지 나온다는 뜻
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;
rendrer.color = new Color(130 / 255f, 130 / 255f, 1f, 1f);
}
else if(type == 3)
{
size = 1.2f;
score = 3;
rendrer.color = new 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);
}
}
}
[오류 내용]
Assets\Scripts\Rain.cs(9,9): warning CS0414: The field 'Rain.score' is assigned but its value is never used
