CatController
csharp
닫기using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CatController : MonoBehaviour
{
private Rigidbody2D rBody2D;
public float moveSpeed = 2f;
// Start is called before the first frame update
void Start()
{
this.rBody2D = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxisRaw("Horizontal");
if (h != 0)
{
this.transform.localScale = new Vector3(h, 1, 1);
}
if(h >= 1)
{
// 오른쪽으로 이동할 경우
this.transform.Translate(Vector3.right * moveSpeed * Time.deltaTime);
}
else if(h <= -1)
{
// 왼쪽으로 이동할 경우
this.transform.Translate(Vector3.left * moveSpeed * Time.deltaTime);
}
}
}

수정해야하는 것 - 가만히 있을 때 가만히 있기..
'유니티 기초 > 복습' 카테고리의 다른 글
SimpleRPG 복습 (0) | 2023.08.08 |
---|---|
로비씬, 사과, 폭탄 [복습] (0) | 2023.08.08 |
챕터 5 고양이 탈출 복습 - [완] (0) | 2023.08.04 |
챕터5 고양이탈출 - CatEscape - 복습 (0) | 2023.08.02 |
[수업과제] 표창 던지기 - 복습 (0) | 2023.08.02 |