
정신을 차리고 보니 똥맵을 만들었다. 은근히 조작 난이도가 높다
유니티에 익숙해지기 위해서 하는 프로젝트
간단하게 미로를 만든 다음, 공을 굴려서 탈출해보자
public class SphereControl : MonoBehaviour
{
public Rigidbody rig;
public int movePower;
public void Update()
{
if(Input.GetKey(KeyCode.UpArrow))
{
rig.AddForce(Vector3.forward*movePower, ForceMode.Force);
}
if (Input.GetKey(KeyCode.DownArrow))
{
rig.AddForce(Vector3.back * movePower, ForceMode.Force);
}
if (Input.GetKey(KeyCode.LeftArrow))
{
rig.AddForce(Vector3.left * movePower, ForceMode.Force);
}
if (Input.GetKey(KeyCode.RightArrow))
{
rig.AddForce(Vector3.right * movePower, ForceMode.Force);
}
}
}
AddForce로 공을 굴린다. if로만 쓰는 이유는 키를 동시에 누를 수 있기 때문
ForceMode.Force로 해서 자연스러운 증가를 보여준다.

사진과 같이 공을 한 바퀴 돌고와서 골지점에 넣으면 된다
첫 레벨 테스트에서 봤던 시계 시침과 분침 문제다
중간을 기준으로 애들을 회전시켜야 한다
RotateAround를 쓴다

transform.RotateAround(target.transform.position, Vector3.up, 20 * Time.deltaTime);

public class Hour : MonoBehaviour
{
public GameObject target;
public int hour;
public int minute;
public enum Type { 시침, 분침 }
public Type handType;
void Start()
{
if (handType == Type.시침)
{
transform.RotateAround(target.transform.position, Vector3.up, (hour * (360 / 12)) + (minute * (360 / (60 * 12))));
}
else if (handType == Type.분침)
{
transform.RotateAround(target.transform.position, Vector3.up, minute * (360 / 60));
}
}
}


사진과 같이 시각을 입력하면 된다

