[109]-FPS Sample-Robot
현재 무엇을 하고 있는지에 대해서는 아래를 참조.
000-Unity FPS Sample Project
#유니티, 유니티 튜토리얼, 유니티 강좌, Unity, Unity tutorial, HDRP, FPS Sample, 게임 개발, C# FPS Sample은 Unite 2018 LA에서 공개된 프로젝트로 Unity로 제작된 FPS(First Person Shooting) 스타일의 게임..
nampt.tistory.com
Unity FPS Sample 공식 사이트 참조
FPS Sample - A multiplayer shooter game project | Unity
Use it to learn about the latest features in Unity, extract and use the parts you need or use the full project as a starting point for your own games.
unity.com
작성한 프로젝트는 Github을 통해 내려 받으세요
https://github.com/nampt68/Repeat_FPS_Sample/
nampt68/Repeat_FPS_Sample
Making Unity FPS Sample from zero. Contribute to nampt68/Repeat_FPS_Sample development by creating an account on GitHub.
github.com
지난번에 Import 관련 Script를 작성하여 Skeleton, Twist, TranslateScale Script의 변수에 뼈대 정보를 모두 불러왔었는데, 다시 Project를 열어보니 문제가 있다. Compile Error를 수정하라고 한다.
사실 이것 때문에 몇가지를 시도해 봤는데, 해결책은 의외로 간단한 것이었다.
아직 사용이 확정되지 않은 Script였단 CharacterDebugWindow, FanEditor.cs를 함께 복사하였는데, CharacterDebugWindow에서 Error가 발생했던 것이다.
그래서 그냥 삭제.
그랬더니, 문제 없이 잘 작동한다.
이제 아래 표시한 Script를 추가하자.
Script는 아래의 위치에 저장되어 있다.
Assets/Scripts/Game/Modules/Character/Components
코드는 아래의 더보기 버튼을 누르자.
using System;
using Unity.Entities;
using UnityEngine;
[DisallowMultipleComponent]
public class CharacterPresentationSetup : MonoBehaviour
{
public GameObject geomtry;
public Transform itemAttachBone;
public AbilityUI[] uiPrefabs; // TODO (mogensh) perhaps move UI to their own char presentation (so they are just just char and items)
public Transform weaponBoneDebug;// TODO (mogensh) put these two debug properties somewhere appropriate
public Vector3 weaponOffsetDebug;
[NonSerialized] public Entity character;
[NonSerialized] public bool updateTransform = true;
[NonSerialized] public Entity attachToPresentation;
public bool IsVisible
{
get { return isVisible; }
}
public void SetVisible(bool visible)
{
isVisible = visible;
if (geomtry != null && geomtry.activeSelf != visible)
geomtry.SetActive(visible);
}
[NonSerialized] bool isVisible = true;
}
[DisableAutoCreation]
public class UpdatePresentationRootTransform : BaseComponentSystem<CharacterPresentationSetup>
{
private ComponentGroup Group;
public UpdatePresentationRootTransform(GameWorld world) : base(world) { }
protected override void Update(Entity entity, CharacterPresentationSetup charPresentation)
{
if (!charPresentation.updateTransform)
return;
if (charPresentation.attachToPresentation != Entity.Null)
return;
var animState = EntityManager.GetComponentData<CharacterInterpolatedData>(charPresentation.character);
charPresentation.transform.position = animState.position;
charPresentation.transform.rotation = Quaternion.Euler(0f, animState.rotation, 0f);
}
}
[DisableAutoCreation]
public class UpdatePresentationAttachmentTransform : BaseComponentSystem<CharacterPresentationSetup>
{
public UpdatePresentationAttachmentTransform(GameWorld world) : base(world) { }
protected override void Update(Entity entity, CharacterPresentationSetup charPresentation)
{
if (!charPresentation.updateTransform)
return;
if (charPresentation.attachToPresentation == Entity.Null)
return;
if (!EntityManager.Exists(charPresentation.attachToPresentation))
{
GameDebug.LogWarning("Huhb ?");
return;
}
var refPresentation =
EntityManager.GetComponentObject<CharacterPresentationSetup>(charPresentation.attachToPresentation);
charPresentation.transform.position = refPresentation.itemAttachBone.position;
charPresentation.transform.rotation = refPresentation.itemAttachBone.rotation;
}
}
AbilityUI를 작성합니다.
FPS Sample에서 위치를 확인합니다.
같은 위치에 같은 이름의 Script를 생성하고,
아래의 코드를 복사한다.
using UnityEngine;
using Unity.Entities;
public abstract class AbilityUI : MonoBehaviour // TODO (mogensh) We should get rid of this a just use charPresentation prefabs to setup UI (same as char and items)
{
public Entity abilityOwner;
public abstract void UpdateAbilityUI(EntityManager entityManager, ref GameTime time);
}
추가한 AbilityUI에서 GameTime struct를 또 구현해야 하는데, 다음에 하기로 한다.
-다소승탁진-
#유니티, 유니티 튜토리얼, 유니티 강좌, Unity, Unity tutorial, HDRP, FPS Sample, 게임 개발, C#