rrrrr
This commit is contained in:
parent
cb9cf36c58
commit
b4b5254950
@ -7,6 +7,7 @@ public sealed class Kal : Component
|
||||
{
|
||||
[RequireComponent] private ShrimpleCharacterController.ShrimpleCharacterController Controller { get; set; }
|
||||
[RequireComponent] private AnimationHelper AnimationHelper { get; set; }
|
||||
[RequireComponent] private RagdollController RagdollController { get; set; }
|
||||
public SkinnedModelRenderer Renderer { get; set; }
|
||||
[Property] public GameObject Body { get; set; }
|
||||
[Property] public GameObject CameraPivot { get; set; }
|
||||
@ -27,6 +28,7 @@ public sealed class Kal : Component
|
||||
|
||||
Controller = Components.Get<ShrimpleCharacterController.ShrimpleCharacterController>();
|
||||
AnimationHelper = Components.Get<AnimationHelper>();
|
||||
RagdollController = Components.Get<RagdollController>();
|
||||
|
||||
if ( !Network.IsOwner ) return;
|
||||
|
||||
@ -44,7 +46,8 @@ public sealed class Kal : Component
|
||||
|
||||
if ( Network.IsOwner )
|
||||
{
|
||||
var wishDirection = Input.AnalogMove.Normal * Rotation.FromYaw( EyeAngles.yaw );
|
||||
var multiplier = RagdollController.Enabled ? 0f : 1f;
|
||||
var wishDirection = Input.AnalogMove.Normal * multiplier * Rotation.FromYaw( EyeAngles.yaw );
|
||||
var isDucking = Input.Down( "Duck" );
|
||||
var isRunning = Input.Down( "Run" );
|
||||
var wishSpeed = isDucking ? DuckSpeed :
|
||||
|
@ -3,31 +3,36 @@ public sealed class RagdollController : Component
|
||||
{
|
||||
[Group("Setup"), Order(-100), Property] public ModelPhysics bodyPhysics { get; set; }
|
||||
[Group("Setup"), Order(-100), Property] public SkinnedModelRenderer bodyRenderer { get; set; }
|
||||
|
||||
[Group("Config"), Order(0), Property, Range(0, 15)] public int impaledPhysicsBodyIndex { get; set; }
|
||||
[Group("Config"), Order(0), Property] public bool isLocked { get; set; }
|
||||
[Group("Runtime"), Order(100), Property] public PhysicsBody impaledPhysicsBody { get; set; }
|
||||
|
||||
// Sensible Indexes
|
||||
// 3 - HEad
|
||||
|
||||
[Sync]
|
||||
private bool Enabled
|
||||
public bool Enabled
|
||||
{
|
||||
get => bodyPhysics.Enabled;
|
||||
set
|
||||
private set
|
||||
{
|
||||
Log.Info(value);
|
||||
bodyPhysics.Enabled = value;
|
||||
bodyPhysics.MotionEnabled = value;
|
||||
bodyRenderer.UseAnimGraph = !value;
|
||||
|
||||
if ( !value )
|
||||
{
|
||||
GameObject.WorldPosition = bodyRenderer.WorldPosition;
|
||||
bodyRenderer.GameObject.LocalPosition = Vector3.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateBody()
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
//impaledPhysicsBodyIndexRemapped = GetClosestSafeIndex(impaledPhysicsBodyIndex);
|
||||
|
||||
if ( Network.IsOwner )
|
||||
{
|
||||
if (Input.Pressed( "Ragdoll" ))
|
||||
{
|
||||
Enabled = !Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
var bodyLock = new PhysicsLock();
|
||||
bodyLock.Pitch = isLocked;
|
||||
bodyLock.Yaw = isLocked;
|
||||
@ -38,86 +43,5 @@ public sealed class RagdollController : Component
|
||||
|
||||
bodyPhysics.Locking = bodyLock;
|
||||
bodyPhysics.MotionEnabled = !isLocked;
|
||||
|
||||
if (isLocked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bodyPhysics.Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
impaledPhysicsBody = bodyPhysics.PhysicsGroup.Bodies.ElementAt(impaledPhysicsBodyIndex);
|
||||
|
||||
var followToPos = GameObject.Transform.World.Position;// - (GameObject.Transform.World.Forward * 30.0f);
|
||||
|
||||
// If this was
|
||||
if (impaledPhysicsBodyIndex == Bones.Terry.spine_0)
|
||||
{
|
||||
followToPos += Vector3.Up * 10.0f;
|
||||
}
|
||||
|
||||
//hitPhysicsBody.Position = followToPos;
|
||||
var delta = Vector3.Direction(impaledPhysicsBody.Position, followToPos);
|
||||
|
||||
impaledPhysicsBody.Velocity = delta * 500.0f;
|
||||
//impaledPhysicsBody.Velocity = Vector3.Zero;
|
||||
//impaledPhysicsBody.Position = MathY.MoveTowards(impaledPhysicsBody.Position, followToPos, Time.Delta * 100.0f);
|
||||
//Log.Info($"delta.Length: {delta.Length}, impaledByHarpoonSpear.isInFlight: {impaledByHarpoonSpear.isInFlight}");
|
||||
|
||||
bool useOriginalMethod = true;
|
||||
if (useOriginalMethod) //delta.Length < 15.0f)// && !impaledByHarpoonSpear.isInFlight)
|
||||
{
|
||||
impaledPhysicsBody.Velocity = delta * 1000.0f;
|
||||
impaledPhysicsBody.Velocity = Vector3.Zero;
|
||||
impaledPhysicsBody.AngularVelocity = MathY.MoveTowards(impaledPhysicsBody.AngularVelocity, Vector3.Zero, Time.Delta * 15.0f);
|
||||
impaledPhysicsBody.AngularVelocity = Vector3.Zero;
|
||||
impaledPhysicsBody.Position = followToPos;
|
||||
|
||||
|
||||
|
||||
//impaledPhysicsBody.Velocity = delta * 100.0f;
|
||||
//impaledPhysicsBody.Position = MathY.MoveTowards(impaledPhysicsBody.Position, followToPos, Time.Delta * 1000.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
float smoothRate = 0.075f;
|
||||
smoothRate = 0.0001f;
|
||||
|
||||
float smoothRateRot = 0.075f;
|
||||
//smoothRateRot = 0.0001f;
|
||||
|
||||
|
||||
var velocity = impaledPhysicsBody.Velocity;
|
||||
Vector3.SmoothDamp(impaledPhysicsBody.Position, WorldPosition, ref velocity, smoothRate, Time.Delta);
|
||||
impaledPhysicsBody.Velocity = velocity;
|
||||
|
||||
var angularVelocity = impaledPhysicsBody.AngularVelocity;
|
||||
Rotation.SmoothDamp(impaledPhysicsBody.Rotation, WorldRotation, ref angularVelocity, smoothRateRot, Time.Delta);
|
||||
impaledPhysicsBody.AngularVelocity = angularVelocity;
|
||||
|
||||
//impaledPhysicsBody.AngularVelocity = Vector3.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
if ( Network.IsOwner )
|
||||
{
|
||||
if (Input.Pressed( "Ragdoll" ))
|
||||
{
|
||||
Log.Info(123123);
|
||||
Enabled = !Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateBody();
|
||||
}
|
||||
|
||||
protected override void OnFixedUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user