강의

멘토링

커뮤니티

Inflearn コミュニティ Q&A

dohap991030 のプロフィール画像
dohap991030

投稿した質問数

UnityとC#で学ぶ カタナゼロスタイルゲームの作り方 (基本編)

プレイヤー移動

스크립트 오류 관련

作成

·

283

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;

    }

}

 

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

unityC#

回答 2

0

cosart님의 프로필 이미지
cosart
インストラクター

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

 

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

 

using System.Collections;

 

using System.Collections.Generic;

 

using UnityEngine;

 

 

 

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

 

 

0

cosart님의 프로필 이미지
cosart
インストラクター

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

dohap991030님의 프로필 이미지
dohap991030
質問者

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

cosart님의 프로필 이미지
cosart
インストラクター

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

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

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

 

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

dohap991030님의 프로필 이미지
dohap991030
質問者

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

cosart님의 프로필 이미지
cosart
インストラクター

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

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

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

 

dohap991030 のプロフィール画像
dohap991030

投稿した質問数

質問する