유니티 기초/복습

챕터6 ClimbCloud [미완] - 복습

다모아 2023. 8. 4. 02:05

CatController

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);
        }


    }
}

 

수정해야하는 것 - 가만히 있을 때 가만히 있기..