Skip to content
Home » 유니티 캐릭터 컨트롤러 | [Unity 3D Basic] 01. Charactercontroller 기반의 오브젝트 이동 188 개의 새로운 답변이 업데이트되었습니다.

유니티 캐릭터 컨트롤러 | [Unity 3D Basic] 01. Charactercontroller 기반의 오브젝트 이동 188 개의 새로운 답변이 업데이트되었습니다.

당신은 주제를 찾고 있습니까 “유니티 캐릭터 컨트롤러 – [Unity 3D Basic] 01. CharacterController 기반의 오브젝트 이동“? 다음 카테고리의 웹사이트 https://kk.taphoamini.com 에서 귀하의 모든 질문에 답변해 드립니다: https://kk.taphoamini.com/wiki. 바로 아래에서 답을 찾을 수 있습니다. 작성자 고박사의 유니티 노트 이(가) 작성한 기사에는 조회수 13,122회 및 좋아요 169개 개의 좋아요가 있습니다.

Table of Contents

유니티 캐릭터 컨트롤러 주제에 대한 동영상 보기

여기에서 이 주제에 대한 비디오를 시청하십시오. 주의 깊게 살펴보고 읽고 있는 내용에 대한 피드백을 제공하세요!

d여기에서 [Unity 3D Basic] 01. CharacterController 기반의 오브젝트 이동 – 유니티 캐릭터 컨트롤러 주제에 대한 세부정보를 참조하세요

유니티 3D 게임 개발을 위한 기초 동영상 입니다.
In this video you will learn how to create 3D game development for beginner.
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
00:00 Intro
00:10 CharacterController 컴포넌트
00:43 게임 월드 구성, 플레이어 캐릭터 제작
02:39 플레이어 캐릭터 이동
04:04 중력 적용
05:56 플레이어 캐릭터 점프
07:26 경사면 이동과 계단 이동
08:58 1인칭 카메라 제어
패키지 (게임 월드)
https://drive.google.com/file/d/1-YsRi3C-v1lFrpyIJW4ec2JGx9SF-F_a/view?usp=sharing
프로젝트 (Unity 2019.3.6f1)
https://drive.google.com/file/d/1Q-aF2L68JLY3Me2qFfqrfCkeGOwOoaJ2/view?usp=sharing
앞으로 올라올 많은 강좌를 쉽게 보려면?
구독(Subscribe), 좋아요(Like)를 눌러주세요!!
감사합니다.

유니티 캐릭터 컨트롤러 주제에 대한 자세한 내용은 여기를 참조하세요.

캐릭터 컨트롤러 – Unity 매뉴얼

캐릭터 컨트롤러(Character Controller) 는 Rigbody 물리를 활용하지 않는 3인 또는 1인 플레이어에 주로 사용됩니다.

+ 여기에 자세히 보기

Source: docs.unity3d.com

Date Published: 9/25/2021

View: 6751

[Unity3D] Character Controller를 이용한 캐릭터 움직임.

Character Controller을 이용해 구현할 움직임은,. 1. 오른쪽, 왼쪽, 위, 아래 움직임. 2. 캐릭터 점프. 3. 경사면 이동.

+ 여기에 보기

Source: truecode.tistory.com

Date Published: 12/27/2021

View: 4903

[ Unity3D ] Character Controller란? – 웹 개발의 기록들 – 티스토리

[ Unity3D ] Character Controller란? … 안녕하세요. 쉽게 배우는 코딩 베오코입니다. 캐릭터 컨트롤러란 무엇인 지 한 번 알아보도록 하겠습니다. 1 ) …

+ 여기를 클릭

Source: includecoding.tistory.com

Date Published: 9/8/2021

View: 4589

[Unity] Charactor Controller – 로메오의 블로그 – 티스토리

Camera를 선택하고 위치를 조절합니다. Character Controller. Capsule을 추가하고. Player라고 이름 바꿉니다.

+ 여기에 보기

Source: romeoh.tistory.com

Date Published: 9/29/2022

View: 5026

[유니티] 캐릭터컨트롤러(CharacterController) 속성 및 스크립팅 …

유니티에서 플레이어의 움직임을 구현할 때 리지드바디와 견주어서 가장 많이 사용되는 것이 캐릭터컨트롤러이다. 캐릭터컨트롤러는, 물리엔진을 사용 …

+ 여기에 자세히 보기

Source: coding-of-today.tistory.com

Date Published: 4/21/2021

View: 9644

유니티 캐릭터 컨트롤러 | [Unity 3D Basic] 01 …

[Unity3D] Character Controller를 이용한 캐릭터 움직임. 캐릭터 컨트롤러의 목록을 살펴보도록 하자. Slope Limit – 콜라이더가 표시된 값 이하의 …

+ 여기에 더 보기

Source: you.1111.com.vn

Date Published: 5/7/2021

View: 962

[유니티(unity)/캐릭터이동] CharacterController 이용한 캐릭터 …

[유니티(unity)/캐릭터이동] CharacterController 이용한 캐릭터 이동 … 캐릭터의 이동은 유니티에서 제공되는 스크립트로 간단하고 유용하게 컨트롤된다.

+ 여기를 클릭

Source: gofogo.tistory.com

Date Published: 10/18/2021

View: 6393

주제와 관련된 이미지 유니티 캐릭터 컨트롤러

주제와 관련된 더 많은 사진을 참조하십시오 [Unity 3D Basic] 01. CharacterController 기반의 오브젝트 이동. 댓글에서 더 많은 관련 이미지를 보거나 필요한 경우 더 많은 관련 기사를 볼 수 있습니다.

[Unity 3D Basic] 01. CharacterController 기반의 오브젝트 이동
[Unity 3D Basic] 01. CharacterController 기반의 오브젝트 이동

주제에 대한 기사 평가 유니티 캐릭터 컨트롤러

  • Author: 고박사의 유니티 노트
  • Views: 조회수 13,122회
  • Likes: 좋아요 169개
  • Date Published: 2020. 3. 29.
  • Video Url link: https://www.youtube.com/watch?v=NQg1_NVi-6o

Unity 매뉴얼

캡슐 콜라이더 캐릭터 조인트

캐릭터 컨트롤러

캐릭터 컨트롤러(Character Controller) 는 Rigidbody 물리를 활용하지 않는 3인 또는 1인 플레이어에 주로 사용됩니다.

프로퍼티

프로퍼티: 기능: Slope Limit 콜라이더가 명시된 값보다 작은 경사(단위:도)의 슬로프만 오르도록 제한합니다. Step Offset 명시된 값보다 계단이 땅에 가까울 경우에만 캐릭터가 계단을 오릅니다. 이 값은 캐릭터 컨트롤러의 높이보다 커서는 안됩니다. 값이 더 클 경우 오류가 발생합니다. Skin width 두 콜라이더가 서로 스킨 너비 만큼 관통할 수 있습니다. 스킨 너비가 클수록 지터링이 감소합니다. 스킨 너비가 작을 경우에는 캐릭터가 움직이지 못할 수 있습니다. 스킨 너비 값을 반지름의 10%로 설정하는 것이 좋습니다. Min Move Distance 캐릭터가 지정한 값보다 낮게 움직이려고 할 경우 아예 움직이지 않게 됩니다. 지터링을 줄이기 위해 이 옵션을 사용할 수 있습니다. 대부분의 경우 이 값은 0으로 두어야 합니다. Center 월드 공간에서 캡슐 콜라이더를 오프셋하며, 캐릭터의 피벗에는 영향을 주지 않습니다. Radius 캡슐 콜라이더의 반지름 길이입니다. 본질적으로는 콜라이더의 너비입니다. Height 캐릭터의 Capsule Collider 높이입니다. 이 값을 변경하면 콜라이더가 Y축을 따라 양의 방향과 음의 방향으로 스케일합니다.

캐릭터 컨트롤러

세부 정보

일반적인 둠 스타일의 1인칭 컨트롤은 물리적으로 사실적이지 않습니다. 캐릭터는 시간당 90마일을 달리고, 즉시 멈추며, 급선회하기도 합니다. 매우 비현실적이기 때문에 이러한 동작을 만드는 것은 실용적이지 않으며 좋은 방법도 아닙니다. 해결책은 특수 캐릭터 컨트롤러를 사용하는 것입니다. 이 컨트롤러는 단순한 캡슐 형태의 Collider 로 스크립트를 통해 일부 방향으로 이동시킬 수 있습니다. 이 컨트롤러는 지시에 따라 이동을 수행하되 충돌이 있을 경우 제약을 받습니다. 벽을 따라 올라가며, (계단이 Step Offset 보다 낮을 경우)계단을 올라가고, Slope Limit 내의 경사를 오릅니다.

컨트롤러는 자체의 힘에는 반응하지 않으며 자동으로 리지드바디를 푸시하지 않습니다.

캐릭터 컨트롤러를 이용하여 리지드바디나 오브젝트를 푸시하고 싶을 경우, 스크립팅을 통해 OnControllerColliderHit() 함수를 사용하여 컨트롤러와 충돌하는 모든 오브젝트에 힘을 적용할 수 있습니다.

한편, 플레이어 캐릭터가 물리에 의해 영향을 받도록 하고 싶을 경우, 캐릭터 컨트롤러 대신 Rigidbody를 사용하는 것이 좋습니다.

캐릭터 미세 튜닝하기

캐릭터의 메시에 맞게 Height 와 Radius 를 수정할 수 있습니다. 인간과 유사한 캐릭터의 경우에는 항상 2미터 정도로 설정할 것을 권장합니다. 피벗 포인트가 캐릭터의 정중앙에 있지 않은 경우에는 캡슐의 Center 도 수정할 수 있습니다.

Step Offset 도 영향을 미칠 수 있습니다. 2미터 크기의 인간일 경우 이 값을 0.1 0 .4로 설정해야 합니다.

Slope Limit 는 너무 작아서는 안됩니다. 90°로 설정하는 것이 가장 좋은 경우가 많습니다. 캐릭터 컨트롤러는 캡슐 모양을 하고 있기 때문에 벽을 올라갈 수 없을 것입니다.

지형물에 걸리지 않기

Skin Width__는 캐릭터 컨트롤러를 조정할 때 가장 중요한 프로퍼티 중 하나입니다. 캐릭터가 움직이지 못할 경우 대부분 Skin Width__가 너무 작아서일 때가 많습니다. __Skin Width__에 따라 오브젝트가 컨트롤러를 약간 관통할 수 있지만 지터링이 제거되고 캐릭터가 걸려 움직이지 못하는 현상을 피할 수 있습니다.

Skin Width 를 최소 0.01보다 크고, Radius 의 10%보다 크게 설정하는 것이 좋습니다.

Min Move Distance 를 0으로 유지할 것을 권장합니다.

여기에서 캐릭터 컨트롤러 스크립트 레퍼런스를 참조하십시오.

힌트

캐릭터가 자주 걸릴 경우 Skin Width 를 조정해보십시오.

를 조정해보십시오. 스크립트를 직접 작성할 경우 캐릭터 컨트롤러가 물리를 사용하는 오브젝트에 영향을 줄 수 있습니다.

캐릭터 컨트롤러는 물리를 통해 오브젝트에 의해 영향을 받지 않습니다.

인스펙터의 캐릭터 컨트롤러 프로퍼티를 변경하면 씬에 있는 컨트롤러가 재생성됩니다. 따라서 기존의 모든 트리거 컨택트가 사라져서 컨트롤러가 다시 움직이기 전까지 OnTriggerEntered 메시지를 받지 못합니다.

레이캐스트를 비롯하여 쿼리에서 사용되는 캐릭터 컨트롤러의 캡슐은 조금 줄어들 수 있습니다. 따라서 일부 코너의 경우 쿼리가 누락될 수 있으며, 이는 쿼리가 캐릭터 컨트롤러의 기즈모에 닿는 것처럼 보일 때도 마찬가지입니다.

참된코딩 :: [Unity3D] Character Controller를 이용한 캐릭터 움직임.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

using System .Collections; using System .Collections.Generic; using UnityEngine; public class Player2 : MonoBehaviour { public float speed; // 캐릭터 움직임 스피드. public float jumpSpeedF; // 캐릭터 점프 힘. public float gravity; // 캐릭터에게 작용하는 중력. private CharacterController controller; // 현재 캐릭터가 가지고있는 캐릭터 컨트롤러 콜라이더. private Vector3 MoveDir; // 캐릭터의 움직이는 방향. void Start() { speed = 6. 0f; jumpSpeed = 8. 0f; gravity = 20. 0f; MoveDir = Vector3.zero; controller = GetComponent < CharacterController > (); } void Update() { // 현재 캐릭터가 땅에 있는가? if (controller.isGrounded) { // 위, 아래 움직임 셋팅. MoveDir = new Vector3(Input.GetAxis( “Horizontal” ), 0 , Input.GetAxis( “Vertical” )); // 벡터를 로컬 좌표계 기준에서 월드 좌표계 기준으로 변환한다. MoveDir = transform.TransformDirection(MoveDir); // 스피드 증가. MoveDir * = speed; // 캐릭터 점프 if (Input.GetButton( “Jump” )) MoveDir.y = jumpSpeed; } // 캐릭터에 중력 적용. MoveDir.y – = gravity * Time.deltaTime; // 캐릭터 움직임. controller.Move(MoveDir * Time.deltaTime); } } Colored by Color Scripter

[ Unity3D ] Character Controller란?

반응형

안녕하세요. 쉽게 배우는 코딩 베오코입니다.

캐릭터 컨트롤러란 무엇인 지 한 번 알아보도록 하겠습니다.

1 ) 캐릭터 컨트롤러란?

– 캐릭터 컨트롤러는, 리지드 바디를 다루지 않습니다. 그리고 충돌에 의한 움직임을 다루기 쉽게 해줍니다.

즉 이 말은 무엇이냐면, 캐릭터 컨트롤러라는 컴포넌트 하나만 있다면, 리지드 바디 컴포넌트가 없어도 물리 연산이 가능해지고

캐릭터 컨트롤러는 default로 Capsule Collider로 이루어져 있기 때문에 굳이 충돌체를 따로 붙여 줄 필요가 없습니다.

하지만! 유니티에서는 플레이어 캐릭터가 물리에 의해 영향을 받도록 하고 싶다면

캐릭터 컨트롤러 대신 RigidBody를 사용하는 것이 좋다고 권장되고 있습니다.

2 ) 캐릭터 컨트롤러 property

– Slope Limit : 콜라이더가 명시 된 값보다 작은 경사의 slope만 오르도록 제한합니다.

– Step Offset : 명시 된 값보다 계단이 땅에 가까울 경우에만 캐릭터가 계단을 오릅니다.

이 값은 캐릭터 컨트롤러의 높이보다 커서는 안됩니다. 값이 더 크면 오류가 발생합니다.

– Skim width : 두 콜라이더가 서로 스킨의 너비 만큼 관통할 수 있습니다. 스킨의 너비가 클수록 지터링이 감소합니다.

스킨 너비가 작을 경우엔 캐릭터가 움직이지도 않을 수 있습니다. 스킨 너비 값을 radius의 10%로 설정하는 것이 좋습니다.

※ 지터링이란 ? 쉽게 설명해서, 덜덜 떨리는 현상이라고 생각하면 될 것.

– Min Move Distance : 캐릭터가 지정한 값보다 낮게 움직이려고 할 경우, 아예 움직이지 않게 된다.

지터링을 줄이기 위해, 이 옵션을 사용할 수 있지만, 대 부분의 경우는 값을 0으로 두어야 한다.

– Center : 월드 공간에서 캡슐 콜라이더를 offset하며, 캐릭터의 pivot에는 영향을 주지 않는다.

– Radius : Capsule Collider의 반지름 길이. 본질적으로는 콜라이더의 너비를 뜻함.

– Height : 캐릭터의 Capsule Collider 높이. 이 값을 변경하면 콜라이더가 Y축을 따라 +,- 방향으로 Scale한다.

3 ) 캐릭터 컨트롤러의 멤버 함수 및 변수

– 이 부분은, 유니티 API 문서에 설명이 잘 되어 있기 때문에, 해당 문서를 보시면서 파악하시는 것을 추천드립니다.

캐릭터 컨트롤러 <- 링크를 클릭하시면 API 문서로 넘어갑니다. 지금까지 캐릭터 컨트롤러에 대해서 알아봤습니다. 일단 기본적인 내용으로만 글을 올렸기 때문에, 조금 더 전문적으로 알고 싶으시다면 유튜브나 다른 블로그를 더 참조해서 공부하시는 것을 추천드립니다. 감사합니다! 반응형

[Unity] Charactor Controller

반응형

Blender, Unity 목록

Version 2019.3.6f1

GameWorld

Gameworld를 Import 합니다.

Prefabs의 GameWorld를 Scene에 올립니다.

Camera를 선택하고 위치를 조절합니다.

Character Controller

Capsule을 추가하고

Player라고 이름 바꿉니다.

Material을 추가하고 Player로 이름 바꾸고 색깔은 빨간색으로 합니다.

Player를 선택하고 Material > Element를 Player Material을 연결합니다.

Player에서 Character Controller를 추가하고

Capsule Collider는 삭제합니다.

Mesh Render를 끄면 충돌범위를 확인 할 수 있습니다.

Script 작성

Movement3D 스크립트를 생성합니다.

PlayerController 스크립트도 생성합니다.

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement3D : MonoBehaviour { [SerializeField] private float moveSpeed = 5.0f; private Vector3 moveDirector; private CharacterController characterController; private void Awake() { characterController = GetComponent(); } private void Update() { characterController.Move(moveDirector * moveSpeed * Time.deltaTime); } public void MoveTo(Vector3 director) { moveDirector = director; } }

using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { private Movement3D movement3D; private void Awake() { movement3D = GetComponent(); } private void Update() { float x = Input.GetAxisRaw(“Horizontal”); float z = Input.GetAxisRaw(“Vertical”); movement3D.MoveTo(new Vector3(x, 0, z)); } }

Player를 선택하고 Movement3D와 CharacterController 스크립트를 넣어 줍니다.

Play해서 키보드 방향키로 이동해봅니다.

중력추가

중력을 위해서 스크립트를 수정합니다.

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement3D : MonoBehaviour { [SerializeField] private float moveSpeed = 5.0f; private float gravity = -9.8f; // 충력계수 private Vector3 moveDirector; private CharacterController characterController; private void Awake() { characterController = GetComponent(); } private void Update() { if ( characterController.isGrounded == false ) { moveDirector.y += gravity * Time.deltaTime; } characterController.Move(moveDirector * moveSpeed * Time.deltaTime); } public void MoveTo(Vector3 direction) { //moveDirector = direction; moveDirector = new Vector3(direction.x, moveDirector.y, direction.z); } }

Play 해서 y축을 변경해보면 중력이 작동합니다.

Jump 구현

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement3D : MonoBehaviour { [SerializeField] private float moveSpeed = 5.0f; [SerializeField] private float jumpForce = 3.0f; private float gravity = -9.8f; // 충력계수 private Vector3 moveDirector; private CharacterController characterController; private void Awake() { characterController = GetComponent(); } private void Update() { if ( characterController.isGrounded == false ) { moveDirector.y += gravity * Time.deltaTime; } characterController.Move(moveDirector * moveSpeed * Time.deltaTime); } public void MoveTo(Vector3 direction) { //moveDirector = direction; moveDirector = new Vector3(direction.x, moveDirector.y, direction.z); } public void JumpTo() { if ( characterController.isGrounded == true ) { moveDirector.y = jumpForce; } } }

using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { [SerializeField] private KeyCode jumpKeyCode = KeyCode.Space; private Movement3D movement3D; private void Awake() { movement3D = GetComponent(); } private void Update() { float x = Input.GetAxisRaw(“Horizontal”); float z = Input.GetAxisRaw(“Vertical”); movement3D.MoveTo(new Vector3(x, 0, z)); if ( Input.GetKeyDown(jumpKeyCode) ) { movement3D.JumpTo(); } } }

게임을 Play해서 Space키로 점프 해봅니다.

경사면 오르기

Character Controller의 Slope Limit 이 45도로 되어 있습니다.

경사면 30도는 오를 수 있습니다.

경사면 50도는 오르지 못합니다.

계단오르기

Step Offset이 0.3 입니다.

두 계단 간 Offset이 0.4 입니다.

계단을 오르지 못합니다.

StepOffset을 0.4로 변경합니다.

계단을 오릅니다.

1인칭 카메라 시점 구현

Main Camera를 Player 자식으로 넣어주고

Camera Position을 reset하고 Y를 0.6으로 설정합니다.

카메라가 Player의 눈 정도에 위치합니다.

CameraController 스크립트를 생성합니다.

using UnityEngine; public class CameraController : MonoBehaviour { private float rotateSpeedX = 3; private float rotateSpeedY = 5; private float limitMinX = -80; private float limitMaxX = 50; private float eulerAngleX; private float eulerAngleY; public void RotateTo(float mouseX, float mouseY) { eulerAngleY += mouseX * rotateSpeedX; eulerAngleY -= mouseY * rotateSpeedY; eulerAngleX = ClampAngle(eulerAngleX, limitMinX, limitMaxX); transform.rotation = Quaternion.Euler(eulerAngleX, eulerAngleY, 0); } private float ClampAngle(float angle, float min, float max) { if (angle < -360) angle += 360; if (angle > 360) angle -= 360; return Mathf.Clamp(angle, min, max); } }

using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { [SerializeField] private KeyCode jumpKeyCode = KeyCode.Space; [SerializeField] private CameraController cameraController; private Movement3D movement3D; private void Awake() { movement3D = GetComponent(); } private void Update() { float x = Input.GetAxisRaw(“Horizontal”); float z = Input.GetAxisRaw(“Vertical”); movement3D.MoveTo(new Vector3(x, 0, z)); if ( Input.GetKeyDown(jumpKeyCode) ) { movement3D.JumpTo(); } float mouseX = Input.GetAxis(“Mouse X”); float mouseY = Input.GetAxis(“Mouse Y”); cameraController.RotateTo(mouseX, mouseX); } }

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement3D : MonoBehaviour { [SerializeField] private float moveSpeed = 5.0f; [SerializeField] private float jumpForce = 3.0f; private float gravity = -9.8f; // 충력계수 private Vector3 moveDirector; [SerializeField] private Transform cameraTransform; private CharacterController characterController; private void Awake() { characterController = GetComponent(); } private void Update() { if ( characterController.isGrounded == false ) { moveDirector.y += gravity * Time.deltaTime; } characterController.Move(moveDirector * moveSpeed * Time.deltaTime); } public void MoveTo(Vector3 direction) { //moveDirector = direction; //moveDirector = new Vector3(direction.x, moveDirector.y, direction.z); Vector3 movedis = cameraTransform.rotation * direction; moveDirector = new Vector3(movedis.x, moveDirector.y, movedis.z); } public void JumpTo() { if ( characterController.isGrounded == true ) { moveDirector.y = jumpForce; } } }

MainCamera를 선택하고 CameraController 스크립트를 넣어줍니다.

Player > Movement 3D와 Player Controller에 각각 MainCamera를 연결해 줍니다.

게임을 Play 하고 마우스로 회전하고, 방향키로 이동 할 수 있습니다.

Blender, Unity 목록

반응형

[유니티] 캐릭터컨트롤러(CharacterController) 속성 및 스크립팅 정리

반응형

유니티에서 플레이어의 움직임을 구현할 때 리지드바디와 견주어서 가장 많이 사용되는 것이 캐릭터컨트롤러이다.

캐릭터컨트롤러는,

물리엔진을 사용하지 않고 간단한 로직만으로 움직임을 구현해주고

자체적으로 콜라이더를 가지고 있기 때문에 어떻게 보면 편리하기도 하다.

그러나… 물리엔진을 쓰지 않는다는 것은 중력작용이나 여러가지 사항들을 직접 코딩해야한다는 뜻이기도 하다.

아무튼 캐릭터컨트롤러로 움직임을 구현해보는 것은 다음 포스팅에서 진행하도록하고

이번에는 캐릭터컨트롤러가 가지고있는 속성값들과 스크립트 상에서 사용가능한 것들을 정리해보고자 한다.

가장 먼저 유니티의 매뉴얼을 살펴보자.

캐릭터 컨트롤러에는 다양한 속성값들이 존재하는데,

움직임을 구현하는 것에 명확한 목적성 때문인지 리지드바디에는 없는 편리한 기능들이 존재한다.

Slope Limit

올라갈수있는 경사도를 설정한다. 45를 입력하면 45도의 경사까지는 플레이어가 올라갈 수 있다.

Step Offset

올라갈수있는 계단의 높이를 설정한다.

당연히 캐릭터의 키보다 작은 값을 입력해야하고 그렇지 않으면 오류가 발생한다.

Skin Width

부딪칠때 겹칠 수 있는 두께를 설정한다.

직역하면 피부두께인데, 말 그대로 피부가 눌리는 것처럼 두 개의 오브젝트가 만났을 때 이 값만큼은 겹쳐진다.

매뉴얼 상에는 반지름의 10%로 설정하는 것을 권장하고 있다.

Min Move Distance

이동할 수있는 최소값을 설정한다. 해당 값보다 적은 거리는 움직이지 않는다.

주어지는 속성 값들만 봐도 알겠지만, 캐릭터의 움직임을 설정하기 위한 값들이 존재한다.

때문에, 캐릭터컨트롤러는 리지드바디의 물리엔진을 사용하지 않는 3인칭이나 1인칭 게임의 경우에 사용하는 것을 권장된다.

이제 다음으로는 캐릭터컨트롤러에 포함되어있는 스크립트들을 확인해보자.

이것 역시도 매뉴얼에 잘 정리되어있다.

캐릭터컨트롤러의 스크립팅도 전부 한번에 공부하려는 것은 비효율적이니,

개발을 진행하면서 다양한 방식의 구현을 시도해보고 그때마다 조금씩 체득하는 것이 좋다.

반응형

유니티 캐릭터 컨트롤러 | [Unity 3D Basic] 01. Charactercontroller 기반의 오브젝트 이동 10021 명이 이 답변을 좋아했습니다

당신은 주제를 찾고 있습니까 “유니티 캐릭터 컨트롤러 – [Unity 3D Basic] 01. CharacterController 기반의 오브젝트 이동“? 다음 카테고리의 웹사이트 https://you.1111.com.vn 에서 귀하의 모든 질문에 답변해 드립니다: you.1111.com.vn/blog. 바로 아래에서 답을 찾을 수 있습니다. 작성자 고박사의 유니티 노트 이(가) 작성한 기사에는 조회수 12,224회 및 좋아요 163개 개의 좋아요가 있습니다.

여기에서 이 주제에 대한 비디오를 시청하십시오. 주의 깊게 살펴보고 읽고 있는 내용에 대한 피드백을 제공하세요!

유니티 3D 게임 개발을 위한 기초 동영상 입니다.

In this video you will learn how to create 3D game development for beginner.

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

00:00 Intro

00:10 CharacterController 컴포넌트

00:43 게임 월드 구성, 플레이어 캐릭터 제작

02:39 플레이어 캐릭터 이동

04:04 중력 적용

05:56 플레이어 캐릭터 점프

07:26 경사면 이동과 계단 이동

08:58 1인칭 카메라 제어

패키지 (게임 월드)

https://drive.google.com/file/d/1-YsRi3C-v1lFrpyIJW4ec2JGx9SF-F_a/view?usp=sharing

프로젝트 (Unity 2019.3.6f1)

https://drive.google.com/file/d/1Q-aF2L68JLY3Me2qFfqrfCkeGOwOoaJ2/view?usp=sharing

앞으로 올라올 많은 강좌를 쉽게 보려면?

구독(Subscribe), 좋아요(Like)를 눌러주세요!!

감사합니다.

캐릭터 컨트롤러(Character Controller) 는 Rigbody 물리를 활용하지 않는 3인 또는 1인 플레이어에 주로 사용됩니다.

+ 더 읽기

Source: docs.unity3d.com

Date Published: 7/3/2021

View: 6659

캐릭터 컨트롤러의 목록을 살펴보도록 하자. Slope Limit – 콜라이더가 표시된 값 이하의 기울기만을 오르도록 한다. => 한 마디로 캐릭터가 경사면과 …

+ 여기에 보기

Source: truecode.tistory.com

Date Published: 7/19/2022

View: 6935

[ Unity3D ] Character Controller란? … 안녕하세요. 쉽게 배우는 코딩 베오코입니다. 캐릭터 컨트롤러란 무엇인 지 한 번 알아보도록 하겠습니다. 1 ) …

+ 여기를 클릭

Source: includecoding.tistory.com

Date Published: 1/22/2022

View: 8022

Camera를 선택하고 위치를 조절합니다. Character Controller. Capsule을 추가하고. Player라고 이름 바꿉니다.

+ 여기에 표시

Source: romeoh.tistory.com

Date Published: 7/4/2022

View: 3455

유니티에서 플레이어의 움직임을 구현할 때 리지드바디와 견주어서 가장 많이 사용되는 것이 캐릭터컨트롤러이다. 캐릭터컨트롤러는, 물리엔진을 사용 …

+ 여기에 자세히 보기

Source: coding-of-today.tistory.com

Date Published: 1/25/2021

View: 3277

3D 물리에서 캐릭터 컨트롤러(Character Controller) 를 사용해 이런 타입의 동작을 만들어낼 수 있습니다. 이 컴포넌트로 캐릭터에게 단순한 형태와 항상 똑바로 서 있는 …

+ 더 읽기

Source: docs.unity.cn

Date Published: 2/28/2022

View: 5567

대체로 게임에서 캐릭터가 이동할때 필요한 기능을 구현해봅니다. 유니티3D 에디터에서. 스크립트 생성. 프로젝트창에서 characterCtrl 스크립트를 생성 …

+ 여기에 더 보기

Source: beatchoi.github.io

Date Published: 6/2/2021

View: 4198

[유니티(unity)/캐릭터이동] CharacterController 이용한 캐릭터 이동 … 캐릭터의 이동은 유니티에서 제공되는 스크립트로 간단하고 유용하게 컨트롤된다.

+ 더 읽기

Source: gofogo.tistory.com

Date Published: 12/17/2021

View: 5453

주제와 관련된 더 많은 사진을 참조하십시오 [Unity 3D Basic] 01. CharacterController 기반의 오브젝트 이동. 댓글에서 더 많은 관련 이미지를 보거나 필요한 경우 더 많은 관련 기사를 볼 수 있습니다.

using System .Collections; using System .Collections.Generic; using UnityEngine; public class Player2 : MonoBehaviour { public float speed; // 캐릭터 움직임 스피드. public float jumpSpeedF; // 캐릭터 점프 힘. public float gravity; // 캐릭터에게 작용하는 중력. private CharacterController controller; // 현재 캐릭터가 가지고있는 캐릭터 컨트롤러 콜라이더. private Vector3 MoveDir; // 캐릭터의 움직이는 방향. void Start() { speed = 6. 0f; jumpSpeed = 8. 0f; gravity = 20. 0f; MoveDir = Vector3.zero; controller = GetComponent < CharacterController > (); } void Update() { // 현재 캐릭터가 땅에 있는가? if (controller.isGrounded) { // 위, 아래 움직임 셋팅. MoveDir = new Vector3(Input.GetAxis( “Horizontal” ), 0 , Input.GetAxis( “Vertical” )); // 벡터를 로컬 좌표계 기준에서 월드 좌표계 기준으로 변환한다. MoveDir = transform.TransformDirection(MoveDir); // 스피드 증가. MoveDir * = speed; // 캐릭터 점프 if (Input.GetButton( “Jump” )) MoveDir.y = jumpSpeed; } // 캐릭터에 중력 적용. MoveDir.y – = gravity * Time.deltaTime; // 캐릭터 움직임. controller.Move(MoveDir * Time.deltaTime); } } Colored by Color Scripter

반응형

Blender, Unity 목록

Version 2019.3.6f1

GameWorld

Gameworld를 Import 합니다.

Prefabs의 GameWorld를 Scene에 올립니다.

Camera를 선택하고 위치를 조절합니다.

Character Controller

Capsule을 추가하고

Player라고 이름 바꿉니다.

Material을 추가하고 Player로 이름 바꾸고 색깔은 빨간색으로 합니다.

Player를 선택하고 Material > Element를 Player Material을 연결합니다.

Player에서 Character Controller를 추가하고

Capsule Collider는 삭제합니다.

Mesh Render를 끄면 충돌범위를 확인 할 수 있습니다.

Script 작성

Movement3D 스크립트를 생성합니다.

PlayerController 스크립트도 생성합니다.

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement3D : MonoBehaviour { [SerializeField] private float moveSpeed = 5.0f; private Vector3 moveDirector; private CharacterController characterController; private void Awake() { characterController = GetComponent (); } private void Update() { characterController.Move(moveDirector * moveSpeed * Time.deltaTime); } public void MoveTo(Vector3 director) { moveDirector = director; } }

using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { private Movement3D movement3D; private void Awake() { movement3D = GetComponent (); } private void Update() { float x = Input.GetAxisRaw(“Horizontal”); float z = Input.GetAxisRaw(“Vertical”); movement3D.MoveTo(new Vector3(x, 0, z)); } }

Player를 선택하고 Movement3D와 CharacterController 스크립트를 넣어 줍니다.

Play해서 키보드 방향키로 이동해봅니다.

중력추가

중력을 위해서 스크립트를 수정합니다.

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement3D : MonoBehaviour { [SerializeField] private float moveSpeed = 5.0f; private float gravity = -9.8f; // 충력계수 private Vector3 moveDirector; private CharacterController characterController; private void Awake() { characterController = GetComponent (); } private void Update() { if ( characterController.isGrounded == false ) { moveDirector.y += gravity * Time.deltaTime; } characterController.Move(moveDirector * moveSpeed * Time.deltaTime); } public void MoveTo(Vector3 direction) { //moveDirector = direction; moveDirector = new Vector3(direction.x, moveDirector.y, direction.z); } }

Play 해서 y축을 변경해보면 중력이 작동합니다.

Jump 구현

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement3D : MonoBehaviour { [SerializeField] private float moveSpeed = 5.0f; [SerializeField] private float jumpForce = 3.0f; private float gravity = -9.8f; // 충력계수 private Vector3 moveDirector; private CharacterController characterController; private void Awake() { characterController = GetComponent (); } private void Update() { if ( characterController.isGrounded == false ) { moveDirector.y += gravity * Time.deltaTime; } characterController.Move(moveDirector * moveSpeed * Time.deltaTime); } public void MoveTo(Vector3 direction) { //moveDirector = direction; moveDirector = new Vector3(direction.x, moveDirector.y, direction.z); } public void JumpTo() { if ( characterController.isGrounded == true ) { moveDirector.y = jumpForce; } } }

using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { [SerializeField] private KeyCode jumpKeyCode = KeyCode.Space; private Movement3D movement3D; private void Awake() { movement3D = GetComponent (); } private void Update() { float x = Input.GetAxisRaw(“Horizontal”); float z = Input.GetAxisRaw(“Vertical”); movement3D.MoveTo(new Vector3(x, 0, z)); if ( Input.GetKeyDown(jumpKeyCode) ) { movement3D.JumpTo(); } } }

게임을 Play해서 Space키로 점프 해봅니다.

경사면 오르기

Character Controller의 Slope Limit 이 45도로 되어 있습니다.

경사면 30도는 오를 수 있습니다.

경사면 50도는 오르지 못합니다.

계단오르기

Step Offset이 0.3 입니다.

두 계단 간 Offset이 0.4 입니다.

계단을 오르지 못합니다.

StepOffset을 0.4로 변경합니다.

계단을 오릅니다.

1인칭 카메라 시점 구현

Main Camera를 Player 자식으로 넣어주고

Camera Position을 reset하고 Y를 0.6으로 설정합니다.

카메라가 Player의 눈 정도에 위치합니다.

CameraController 스크립트를 생성합니다.

using UnityEngine; public class CameraController : MonoBehaviour { private float rotateSpeedX = 3; private float rotateSpeedY = 5; private float limitMinX = -80; private float limitMaxX = 50; private float eulerAngleX; private float eulerAngleY; public void RotateTo(float mouseX, float mouseY) { eulerAngleY += mouseX * rotateSpeedX; eulerAngleY -= mouseY * rotateSpeedY; eulerAngleX = ClampAngle(eulerAngleX, limitMinX, limitMaxX); transform.rotation = Quaternion.Euler(eulerAngleX, eulerAngleY, 0); } private float ClampAngle(float angle, float min, float max) { if (angle < -360) angle += 360; if (angle > 360) angle -= 360; return Mathf.Clamp(angle, min, max); } }

using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { [SerializeField] private KeyCode jumpKeyCode = KeyCode.Space; [SerializeField] private CameraController cameraController; private Movement3D movement3D; private void Awake() { movement3D = GetComponent (); } private void Update() { float x = Input.GetAxisRaw(“Horizontal”); float z = Input.GetAxisRaw(“Vertical”); movement3D.MoveTo(new Vector3(x, 0, z)); if ( Input.GetKeyDown(jumpKeyCode) ) { movement3D.JumpTo(); } float mouseX = Input.GetAxis(“Mouse X”); float mouseY = Input.GetAxis(“Mouse Y”); cameraController.RotateTo(mouseX, mouseX); } }

using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement3D : MonoBehaviour { [SerializeField] private float moveSpeed = 5.0f; [SerializeField] private float jumpForce = 3.0f; private float gravity = -9.8f; // 충력계수 private Vector3 moveDirector; [SerializeField] private Transform cameraTransform; private CharacterController characterController; private void Awake() { characterController = GetComponent (); } private void Update() { if ( characterController.isGrounded == false ) { moveDirector.y += gravity * Time.deltaTime; } characterController.Move(moveDirector * moveSpeed * Time.deltaTime); } public void MoveTo(Vector3 direction) { //moveDirector = direction; //moveDirector = new Vector3(direction.x, moveDirector.y, direction.z); Vector3 movedis = cameraTransform.rotation * direction; moveDirector = new Vector3(movedis.x, moveDirector.y, movedis.z); } public void JumpTo() { if ( characterController.isGrounded == true ) { moveDirector.y = jumpForce; } } }

MainCamera를 선택하고 CameraController 스크립트를 넣어줍니다.

Player > Movement 3D와 Player Controller에 각각 MainCamera를 연결해 줍니다.

게임을 Play 하고 마우스로 회전하고, 방향키로 이동 할 수 있습니다.

Blender, Unity 목록

반응형

캐릭터이동] CharacterController 이용한 캐릭터 이동

반응형

[유니티(unity)/캐릭터이동] CharacterController 이용한 캐릭터 이동

캐릭터의 이동은 유니티에서 제공되는 스크립트로 간단하고 유용하게 컨트롤된다.

희망하는 객체에 CharacterController를 추가한 후

[SerializeField] float moveSpeed = 5.0f; Vector3 moveDirection; private CharacterController characterController; private void Awake() { characterController = GetComponent(); } private void Update() { float x = Input.GetAxisRaw(“Horizontal”); float z = Input.GetAxisRaw(“Vertical”); moveDirection = new Vector3(x, 0, z); characterController.Move(moveDirection * moveSpeed * Time.deltaTime); }

다음 스크립트로 컨트롤하면된다.

moveSpeed : 캐릭터 이동속도

moveDirection : 방향키 커서 방향

후 move에 벡터연산을 통하여 원하는대로 캐릭터가 이동이 가능하다.

# CharacterController #unity #캐릭터이동 #객체이동 #유니티 #캐릭터컨트롤러 #캐릭터 #유저 #모델이동 #모델링이동

반응형

키워드에 대한 정보 유니티 캐릭터 컨트롤러

다음은 Bing에서 유니티 캐릭터 컨트롤러 주제에 대한 검색 결과입니다. 필요한 경우 더 읽을 수 있습니다.

이 기사는 인터넷의 다양한 출처에서 편집되었습니다. 이 기사가 유용했기를 바랍니다. 이 기사가 유용하다고 생각되면 공유하십시오. 매우 감사합니다!

사람들이 주제에 대해 자주 검색하는 키워드 [Unity 3D Basic] 01. CharacterController 기반의 오브젝트 이동

  • 유니티 엔진
  • 유니티 강좌
  • 유니티 3D 기초
[Unity #3D #Basic] #01. #CharacterController #기반의 #오브젝트 #이동


YouTube에서 유니티 캐릭터 컨트롤러 주제의 다른 동영상 보기

주제에 대한 기사를 시청해 주셔서 감사합니다 [Unity 3D Basic] 01. CharacterController 기반의 오브젝트 이동 | 유니티 캐릭터 컨트롤러, 이 기사가 유용하다고 생각되면 공유하십시오, 매우 감사합니다.

See also  썸 바디 윤혜수 | [썸바디2 선공개] 남자들 사로잡았다♡♥ 사전호감도 1위 '윤혜수'의 춤 - 밤편지(아이유)ㅣ내일 저녁 8시 첫방송! 모든 답변

Leave a Reply

Your email address will not be published. Required fields are marked *