-
카테고리
-
세부 분야
게임 프로그래밍
-
해결 여부
미해결
스크립트 오류 관련
21.10.27 20:49 작성 조회수 155
0
public class Player : MonoBehaviour
{
public float speed = 5;
public float jumpUp = 1;
public Vector3 direction;
Animator pAnimator;
Rigidbody2D pRig2D;
SpriteRenderer sp;
// Start is called before the first frame update
void Start()
{
pAnimator = GetComponent<Animator>();
pRig2D = GetComponent<Rididbody2D>();
direction = Vector2.zero;
sp = GetComponenet<SpriteRenderer>();
}
void Keyinput()
{
direction.x = Input.GetAxisRaw("Horizontal"); // left -1 right +1
if (direction.x < 0)
{
// left
sp.flipX = true;
}
else if (direction.x > 0)
{
// right
sp.flipX = false;
}
else if (direction.x == 0)
{
}
}
// Update is called once per frame
void Update()
{
Keyinput();
Move();
}
public void Move()
{
transform.position += direction * speed * Time.deltaTime;
}
}
스크립트에 문제 있는 부분 확인 부탁드립니다
답변을 작성해보세요.
0
코사트
지식공유자2021.11.02
네임스페이스가 없다고하네요.
처음에 스크립트만들면 맨윗줄에
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
이부분이 지워지지 않았는지 확인해보세요.
답변 2