๐จ๐ผ๐ป๊ฐ๋ฐ/์ ๋ํฐ
์ ๋ํฐ - ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ์์น ์ด๋
Janger
2021. 11. 28. 03:26
728x90
[Basic_Move.cs]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Basic_Move : MonoBehaviour
{
public int Speed;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if( Input.GetKey (KeyCode.LeftArrow) ){
transform.Translate ( Vector3.left * Speed * Time.deltaTime );
}
if( Input.GetKey (KeyCode.RightArrow) ){
transform.Translate ( Vector3.right * Speed * Time.deltaTime );
}
if( Input.GetKey (KeyCode.UpArrow) ){
transform.Translate ( Vector3.forward * Speed * Time.deltaTime );
}
if( Input.GetKey (KeyCode.DownArrow) ){
transform.Translate ( Vector3.back * Speed * Time.deltaTime );
}
}
}
์์ ์คํฌ๋ฆฝํธ๋ฅผ ์์ฑํด ์์ง์ด๋ ๋์์ด ์คํฌ๋ฆฝํธ๋ฅผ Add Component๋ฅผ ํ๋ค.
๋ง์ฝ ์์ง์ด๋๋ฐ ์ฐ๋ฌ์ง๊ฑฐ๋ ํ์ ํ๋ ๊ฒ์ ๋ฐฉ์งํ๊ณ ์ถ์ ๊ฒฝ์ฐ Rigidbody ์ปดํฌ๋ํธ๋ฅผ ์์ฑํด Contraints์ ๋ค์ด๊ฐ Freeze Position๊ณผ Freeze Rotation์ ์ฌ์ง๊ณผ ๊ฐ์ด ์์ ํ๋ฉด ๋จ.
์ถ์ฒ:
https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=wlhermit&logNo=192751055
์ ๋ํฐ ๊ฐ์ข - [3๋ถC#] 1. ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ์ด๋ ๋ง๋ค๊ธฐ
+ํด๋น๊ฐ์ข๋์ ๋ํฐ 4.56๋ฒ์ ์ด์ ์์๋ง ๋์ํฉ๋๋ค. ๊ณต์์ ์ธ ๊ฐ์ ์ธ๋ก ๊ทธ๋ฅ ์์ฃผ ๊ฐ๋จํ ํํ ๋ฆฌ์ผ์ ์...
blog.naver.com
728x90