using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameManager : MonoBehaviour
{
ย  ย  void Start()
ย  ย  {
ย  ย  ย  ย  SquareMove smv;
ย  ย  ย  ย  smv = GameObject.Find("Square").GetComponent<SquareMove>();

ย  ย  ย  ย  int i = smv.i;
ย  ย  ย  ย 
ย  ย  }
}







using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SquareMove : MonoBehaviour
{ ย 
ย  ย  public int i = 90;
ย  ย  float h;
ย  ย  float v;
ย  ย  int MoveSpeed = 5;
ย  ย 

ย  ย  Rigidbody2D rigid;

ย  ย  void Start()
ย  ย  {
ย  ย  ย  ย  rigid = GetComponent<Rigidbody2D>();
ย  ย  }

ย  ย  void Update()
ย  ย  {
ย  ย  ย  ย  h = Input.GetAxisRaw("Horizontal");
ย  ย  ย  ย  v = Input.GetAxisRaw("Vertical");
ย  ย  }

ย  ย  void FixedUpdate()
ย  ย  {
ย  ย  ย  ย  rigid.velocity = new Vector2(h,v) * MoveSpeed;
ย  ย  }
}



์œ„์— GameManager์€ GameManager์ด๋ผ๋Š” ์˜ค๋ธŒ์ ํŠธ์— ์žˆ๊ณ ย 

SquareMove๋Š” Square์ด๋ผ๋Š” ์˜ค๋ธŒ์ ํŠธ์— ์žˆ์Œ


๊ทธ๋ฆฌ๊ณ  ๋ณด๋‹ค์‹œํ”ผ ๋‚œ ์Šคํฌ๋ฆฝํŠธ ์ด๋ฆ„์— ๊ณต๋ฐฑ ๋„ฃ์€์  ์—†๋Š”๋ฐ

์ธ์ŠคํŽ™ํ„ฐ ์ฐฝ์—๋Š” Square Move๋ผ๊ณ  ๋„์›Œ์ ธ ์žˆ๋Š”๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ด๋Š”๋ฐ ๊ทธ๊ฒƒ๋•Œ๋ฌธ์ธ๊ฐ€


์ฝ˜์†”์—๋Š” GameManager 12๋ฒˆ์งธ ์ค„์—์„œ ์˜ค๋ฅ˜๋‚ฌ๋Œ€