오늘의 게임 개발 진행도
using UnityEngine;
public class Rtan : MonoBehaviour
{
float direction = 0.05f;
SpriteRenderer renderer;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
Application.targetFrameRate = 60;
renderer = GetComponent<SpriteRenderer>();
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
direction *= -1;
renderer.flipX = !renderer.flipX;
}
if (transform.position.x > 2.6f)
{
renderer.flipX = true;
direction = -0.05f;
}
if (transform.position.x < -2.6f)
{
renderer.flipX = false;
direction = 0.05f;
}
transform.position += Vector3.right * direction;
}
}
캐릭터가 좌우로 움직이며, 벽에 부딪힐때 반대로 가고 마우스로 클릭시에도 방향이 반대로 전환까지의 기능.
게임개발 수행중 발생 문제)
1. GetComponent의 철자중 C를 대문자로 쓰지 않아 캐릭터가 움직이지 않는 상황 발생
2. 코드를 알맞게 수행했으나 캐릭터가 갑자기 제자리에서 발만 움직이는 상황이 발생.
해결방안)
1. 대문자로 고치며 바로 해결완료.
2. 코드는 틀린게 없어서 외부에 문제로 판단.
apply root motion 체크 확인. but 이 문제는 아님.
부모 오브젝트로 되어 있는지 확인. but 이 문제도 아님
->2번 문제는 현재까지 혼자 해결하려고 노력중에 있음.
내일 사전교육 시간까지 해결되지 않는다면 진도에 차질이 생길 수 있기에 외부의 도움을 받을것임.