코드 임포트 및 기초 코드 코딩
오브젝트의 Position, Rotation값 변경
입력 제어 장치 입력값 불러오는 법.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
public class Rtan : MonoBehaviour
{
float direction = 0.05f;
SpriteRenderer renderer;
void Start()
{
Application.targetFrameRate = 60;
Debug.Log("안녕");
renderer = GetComponent<SpriteRenderer>();
/*direction = -0.05f;*/
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
direction *= -1;
renderer.flipX = !renderer.flipX;
}
if (transform.position.x > 2.6f)
{
direction = -0.05f;
renderer.flipX = true;
}
if (transform.position.x < -2.6f)
{
direction = 0.05f;
renderer.flipX = false;
}
transform.position += Vector3.right * direction;
}
}
