• 카테고리

    질문 & 답변
  • 세부 분야

    게임 프로그래밍

  • 해결 여부

    미해결

스크립트 오류 관련

21.10.27 20:49 작성 조회수 153

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;

    }

}

 

스크립트에 문제 있는 부분 확인 부탁드립니다

답변 2

·

답변을 작성해보세요.

0

네임스페이스가 없다고하네요. 

 

처음에 스크립트만들면 맨윗줄에 

 

using System.Collections;

 

using System.Collections.Generic;

 

using UnityEngine;

 

 

 

이부분이 지워지지 않았는지 확인해보세요. 

 

 

0

콘솔 에러 빨간색 캡쳐 해주실수있나요? 어디서 에러났나요?

김도현님의 프로필

김도현

질문자

2021.11.01

이렇게 뜹니다. 답변 감사합니다

네임스페이스가 없다고하네요. 

처음에 스크립트만들면 맨윗줄에 

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

 

이부분이 지워지지 않았는지 확인해보세요. 

김도현님의 프로필

김도현

질문자

2021.11.02

집어넣었는데도 이렇게 뜨네요.. 여러 번 답변 감사합니다

오류가달라져서 좀 잡힌거같은데 

마지막껀 오타같구요 틀린거확인하시고 

마지막 강의에 최종버젼프로젝트있으닌깐 Player.cs파일 한번 열어서 뭐가 다른지 확인해보세요.