๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • Tried. Failed. Logged.
๐Ÿ‘จ๐Ÿผ‍๐Ÿ’ป๊ฐœ๋ฐœ/์œ ๋‹ˆํ‹ฐ

์œ ๋‹ˆํ‹ฐ - ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ์œ„์น˜ ์ด๋™

by Janger 2021. 11. 28.
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