NullReferenceException: Object reference not set to an instance of an object

์ด๋ž€ ์—๋Ÿฌ๊ฐ€ ๋‚˜๊ตฌ์š”


๊ธธ์ด๊ฐ€ 3๋ฏธ๋งŒ์ด๋ฉด์„œ Gํ‚ค๋ฅผ ๋ˆ„๋ฅด๋ฉด ํฌ๊ธฐ๊ฐ€ ์ปค์ ธ์•ผ๋˜๋Š”๋ฐ

๊ฟˆ์ฉ๋„์•ˆํ•˜๋„ค์šฉ...



using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class Legcontroller : MonoBehaviour

{


ย  ย  public float x = 0.1f;

ย  ย  private Transform bodybody;



ย  ย  void start()ย 

ย  ย  {

ย  ย  ย  ย  bodybody = GetComponent();

ย  ย  }




ย  ย  // Update is called once per frame

ย  ย  void Update()

ย  ย  {

ย  ย  ย  ย  if (Input.GetKeyDown(KeyCode.G) && bodybody.localScale.x

ย  ย  ย  ย  {

ย  ย  ย  ย  ย  ย  transform.localScale += new Vector3(x, 0, 0);

ย  ย  ย  ย  }

ย  ย  ย  ย ย 

ย  ย  }

}