오늘은 플레이어의 특수능력 중 하나인 슈퍼점프 구현과 다양한 잔버그들을 수정했다. 먼저 플레이어의 무기에 달려있는 콜라이더의 크기가 너무 작아서 크기를 적당히 키워주어 공격판정의 인식범위를 늘리고, 플레이어에 달려있는 카메라에 관련된 잔버그가 많아서 우선 플레이어에게 CameraLookPoint를 설정해 주고 VirtualCamera가 해당 포인트를 찾아가도록 설정했다.
그리고 플레이어에 달린 카메라가 환경안으로 들어갔을 때, 환경 조형물에 콜라이더 설정이 없으면 카메라가 해당 조형물 안으로 들어가서 마치 뚫린듯한 카메라 시각을 연출하게 되는데, 에셋 데모씬에서 해당 던전 Environment를 그대로 가져오다 보니 Mesh가 유실됐었다.
해당 Mesh를 다시 원래대로 넣어주니 카메라가 플레이어를 따라서 잘 작동하면서 별다른 문제가 없는 것을 확인했다.
그리고 플레이어의 특수능력 중 슈퍼점프를 구현하기 위해 새로운 스테이트를 만들었다.
<PlayerSuperJump>
public class PlayerSuperJump : PlayerAirState
{
public PlayerSuperJump(PlayerStateMachine playerstateMachine) : base(playerstateMachine)
{
}
public override void Enter()
{
stateMachine.JumpForce = stateMachine.Player.Data.AirData.JumpForce;
stateMachine.Player.ForceReceiver.Jump(10);
base.Enter();
StartAnimation(stateMachine.Player.AnimationData.SuperJumpParameterHash);
}
public override void Exit()
{
base.Exit();
StopAnimation(stateMachine.Player.AnimationData.SuperJumpParameterHash);
}
public override void PhysicsUpdate()
{
base.PhysicsUpdate();
if (stateMachine.Player.Controller.velocity.y <= 0)
{
stateMachine.ChangeState(stateMachine.FallState);
return;
}
}
}
그리고 스테이트가 추가되면 다른곳에서도 해당 스테이트를 연결시켜주어야 한다.
PlayerAnimationData 수정
public class PlayerAnimationData
{
// 생략
[SerializeField] private string superJumpParameterName = "SuperJump";
// 생략
public int SuperJumpParameterHash { get; private set; }
public void Initialize()
{
// 생략
SuperJumpParameterHash = Animator.StringToHash(superJumpParameterName);
}
}
PlayerBaseState 수정
protected virtual void AddInputActionsCallbacks()
{
// 생략
input.PlayerActions.SuperJump.started += OnSuperJumpStarted;
}
protected virtual void RemoveInputActionsCallbacks()
{
// 생략
input.PlayerActions.SuperJump.started -= OnSuperJumpStarted;
}
protected virtual void OnSuperJumpStarted(InputAction.CallbackContext context)
{
if (stateMachine.Player.Controller.isGrounded)
stateMachine.ChangeState(stateMachine.SuperJump);
}
'TIL (since 2023.08.07 ~ )' 카테고리의 다른 글
2023-11-13 TIL(Unity 최종 프로젝트 16일차) (0) | 2023.11.13 |
---|---|
2023-11-10 TIL(Unity 최종 프로젝트 15일차) (0) | 2023.11.10 |
2023-11-08 TIL(Unity 최종 프로젝트 13일차) (1) | 2023.11.08 |
2023-11-07 TIL(Unity 최종 프로젝트 12일차) (0) | 2023.11.07 |
2023-11-06 TIL(Unity 최종 프로젝트 11일차) (0) | 2023.11.07 |