1
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BITFALL.Guns.States;
|
||||
using BITFALL.Player.Movement;
|
||||
@@ -118,8 +119,16 @@ namespace BITFALL.Guns
|
||||
_playerMovement = entity.Get<IPlayerMovement>();
|
||||
_movement.OnStateChanged += OnMovementStateChanged;
|
||||
_movement.OnCommand += OnMovementCommand;
|
||||
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
actionGroup.UnRegisterCallback(fireAction, OnFire);
|
||||
actionGroup.UnRegisterCallback(aimAction, OnAim);
|
||||
actionGroup.UnRegisterCallback(reloadAction, OnReload);
|
||||
actionGroup.UnRegisterCallback(meleeAction, OnMelee);
|
||||
}
|
||||
|
||||
private void OnMovementCommand(object obj)
|
||||
{
|
||||
switch (obj)
|
||||
|
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lightbug.CharacterControllerPro.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Entities.Player.Movement
|
||||
{
|
||||
public class GravityOnlyCharacterController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private CharacterActor actor;
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
actor.Velocity = Physics.gravity;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -60,6 +60,14 @@ namespace BITFALL.Entities.Player.Movement
|
||||
physics.OnSetPhysics += OnSetPhysics;
|
||||
}
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
foreach (var x in GetComponentsInChildren<Collider>(true))
|
||||
{
|
||||
actor.PhysicsComponent.IgnoreCollision(x.transform,true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSetPhysics(bool obj)
|
||||
{
|
||||
if (obj is false) return;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using Lightbug.Utilities;
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
@@ -15,20 +16,15 @@ namespace BITFALL.Scenes
|
||||
[SerializeField] private float mass;
|
||||
[SerializeField] private Animator animator;
|
||||
[SerializeField] private RigidbodyComponent rigidbodyComponent;
|
||||
private Vector3 currentPosition;
|
||||
private Quaternion currentRotation;
|
||||
private readonly DoubleBuffer<Vector3> currentPosition=new();
|
||||
private readonly DoubleBuffer<Quaternion> currentRotation=new();
|
||||
private void Start()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if(EditorApplication.isPlaying is false)
|
||||
return;
|
||||
#endif
|
||||
rigidbodyComponent = gameObject.AddComponent<RigidbodyComponent3D>();
|
||||
var transform1 = transform;
|
||||
currentPosition = transform1.position;
|
||||
currentRotation=transform1.rotation;
|
||||
rigidbodyComponent.UseGravity = false;
|
||||
rigidbodyComponent.Mass = mass;
|
||||
rigidbodyComponent = RigidbodyComponent.CreateInstance(gameObject);
|
||||
}
|
||||
private void FixedUpdate()
|
||||
{
|
||||
@@ -36,15 +32,16 @@ namespace BITFALL.Scenes
|
||||
if(EditorApplication.isPlaying is false)
|
||||
return;
|
||||
#endif
|
||||
rigidbodyComponent.Velocity = animator.velocity;
|
||||
rigidbodyComponent.AngularVelocity = animator.angularVelocity;
|
||||
rigidbodyComponent.MoveAndRotate(currentPosition,currentRotation);
|
||||
if(currentPosition.TryGetRelease(out var position))
|
||||
rigidbodyComponent.Position = position;
|
||||
if(currentRotation.TryGetRelease(out var rotation))
|
||||
rigidbodyComponent.Rotation = rotation;
|
||||
}
|
||||
private void OnAnimatorMove()
|
||||
{
|
||||
animator.ApplyBuiltinRootMotion();
|
||||
currentPosition = animator.rootPosition;
|
||||
currentRotation = animator.rootRotation;
|
||||
animator.ApplyBuiltinRootMotion();
|
||||
currentPosition.Release(animator.rootPosition);
|
||||
currentRotation.Release(animator.rootRotation);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user