Add ragdolling
This commit is contained in:
parent
e15db6d06a
commit
e516d15cb5
@ -172,7 +172,7 @@ Camera:
|
||||
m_Depth: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 29495
|
||||
m_Bits: 62263
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
@ -419,6 +419,10 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 871240244930749490, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1099499151032430613, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
@ -431,6 +435,10 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1246976274270256316, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1310866226839752315, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
@ -439,6 +447,10 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1348022222591332113, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1425451694149971216, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
@ -487,6 +499,10 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2166701538189745558, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2216733574008521778, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
@ -527,6 +543,10 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2533659176012418518, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2651336681686158176, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
@ -551,10 +571,18 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3318296341598962247, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3404627525641887855, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3418577966610259073, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3586172491057624631, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
@ -579,6 +607,14 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3998051929659402049, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4098651714366577250, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4103164600241655739, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
@ -611,6 +647,10 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4418753410214073174, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4420112016416942592, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
@ -643,6 +683,14 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4815376917716352660, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4930140476332549762, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4958852355926309971, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 11
|
||||
@ -663,6 +711,10 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5505864087486719013, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5541361429010640606, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
@ -679,6 +731,10 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5770237047478321836, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5904574347635162510, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
@ -695,13 +751,17 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6149402365840242429, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6271012460913906906, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6404617181425239302, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
value: 15
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6607538649249053632, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
@ -711,6 +771,10 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6853762624871025803, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6951373490603822597, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 11
|
||||
@ -727,10 +791,18 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7288032834426766273, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7300372765655418654, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7312602481970453879, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7319380595485625436, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
@ -791,6 +863,14 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8167777135514076154, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8223117926796048224, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8348889788496144539, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
@ -815,6 +895,10 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8952193419022929828, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Interpolate
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9121435407391642698, guid: 0bffd92c46c257840806f5e957954800, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 10
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -356,6 +356,10 @@ PrefabInstance:
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 919132149155446097, guid: 4b9b55215c46317428803b7adeda89c3, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 8
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 4b9b55215c46317428803b7adeda89c3, type: 3}
|
||||
--- !u!4 &315509112 stripped
|
||||
|
@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using NeonTea.Quakeball.Players;
|
||||
using NeonTea.Quakeball.Util;
|
||||
|
||||
@ -15,6 +16,9 @@ namespace NeonTea.Quakeball.Animation {
|
||||
public Player Player;
|
||||
public Transform HeadCollider;
|
||||
|
||||
public bool Ragdolling = false;
|
||||
private bool _Ragdolling = false;
|
||||
|
||||
[Header("Gun holding")]
|
||||
public bool GunGluedToHand = true;
|
||||
public Transform Gun;
|
||||
@ -28,6 +32,22 @@ namespace NeonTea.Quakeball.Animation {
|
||||
private float VisualYaw;
|
||||
private float VisualPitch;
|
||||
|
||||
private List<Rigidbody> RagdollParts = new List<Rigidbody>();
|
||||
|
||||
public void StartRagdoll() {
|
||||
Animator.enabled = false;
|
||||
foreach (Rigidbody body in RagdollParts) {
|
||||
body.isKinematic = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void StopRagdoll() {
|
||||
foreach (Rigidbody body in RagdollParts) {
|
||||
body.isKinematic = true;
|
||||
}
|
||||
Animator.enabled = true;
|
||||
}
|
||||
|
||||
private void Awake() {
|
||||
foreach (Animator animator in Soldiers) {
|
||||
animator.gameObject.SetActive(false);
|
||||
@ -41,6 +61,18 @@ namespace NeonTea.Quakeball.Animation {
|
||||
if (GunGluedToHand) {
|
||||
Gun.parent = Animator.transform;
|
||||
}
|
||||
AddRigidbodyToRagdoll(Animator.transform);
|
||||
StopRagdoll();
|
||||
}
|
||||
|
||||
private void AddRigidbodyToRagdoll(Transform t) {
|
||||
Rigidbody body = t.GetComponent<Rigidbody>();
|
||||
if (body != null) {
|
||||
RagdollParts.Add(body);
|
||||
}
|
||||
for (int i = 0; i < t.childCount; i++) {
|
||||
AddRigidbodyToRagdoll(t.GetChild(i));
|
||||
}
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
@ -48,6 +80,15 @@ namespace NeonTea.Quakeball.Animation {
|
||||
float Forward = Vector3.Dot(Player.GroundVelocity, transform.forward) / Player.MoveStyle.TargetVelocity / 0.7f;
|
||||
Animator.SetFloat("Forward", Mathf.Clamp(Forward, -1, 1));
|
||||
Animator.SetFloat("Right", Mathf.Clamp(Right, -1, 1));
|
||||
|
||||
if (Ragdolling != _Ragdolling) {
|
||||
if (Ragdolling) {
|
||||
StartRagdoll();
|
||||
} else {
|
||||
StopRagdoll();
|
||||
}
|
||||
_Ragdolling = Ragdolling;
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate() {
|
||||
|
@ -5,6 +5,7 @@ using NeonTea.Quakeball.Networking;
|
||||
using NeonTea.Quakeball.Networking.Instances;
|
||||
using NeonTea.Quakeball.Combat;
|
||||
using NeonTea.Quakeball.Interface;
|
||||
using NeonTea.Quakeball.Animation;
|
||||
|
||||
namespace NeonTea.Quakeball.Players {
|
||||
/// <summary>The central glue class for players (both local and remote).</summary>
|
||||
@ -20,6 +21,8 @@ namespace NeonTea.Quakeball.Players {
|
||||
public Transform Gun;
|
||||
public Animator GunBobber;
|
||||
|
||||
public SoldierProceduralAnimator SoldierProceduralAnimator;
|
||||
|
||||
[Tooltip("GameObjects that are disabled on death and re-enabled on respawn.")]
|
||||
public GameObject[] DisabledOnDeath;
|
||||
|
||||
@ -100,11 +103,12 @@ namespace NeonTea.Quakeball.Players {
|
||||
|
||||
/// <summary>Updates this Player with the given packet.</summary>
|
||||
public void ProcessUpdatePacket(PlayerUpdatePckt packet) {
|
||||
if (!IsDead) {
|
||||
Pitch = packet.Pitch;
|
||||
Yaw = packet.Yaw;
|
||||
MoveDirection = packet.MoveDirection;
|
||||
CurrentMoveStyle = packet.MoveStyle;
|
||||
packet = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Creates a PlayerSyncPacket representing this Player's position and velocity, for sending to the server.</summary>
|
||||
@ -187,6 +191,7 @@ namespace NeonTea.Quakeball.Players {
|
||||
}
|
||||
|
||||
public void Hit(ulong sourceUid) {
|
||||
Terminal.Singleton.Println($"{NetId} hit sourceIid: {sourceUid}");
|
||||
if (Net.Singleton.Instance is Server) {
|
||||
((Server)Net.Singleton.Instance).HandlePlayerDeath(NetId, sourceUid);
|
||||
}
|
||||
@ -203,6 +208,7 @@ namespace NeonTea.Quakeball.Players {
|
||||
|
||||
/// <summary>Called when this Player is dead</summary>
|
||||
public void Dead(ulong killer) {
|
||||
Terminal.Singleton.Println($"{killer} killed me: {NetId}, deadness currently: {IsDead}");
|
||||
if (IsDead) {
|
||||
return;
|
||||
}
|
||||
@ -211,6 +217,7 @@ namespace NeonTea.Quakeball.Players {
|
||||
GameObject.FindGameObjectWithTag("DeadScreen").GetComponent<DeadScreen>().StartCountdown(name);
|
||||
Net.Singleton.Instance.LocalPlayer.Controlled.GetComponent<LocalPlayer>().DisableInput += 1;
|
||||
}
|
||||
SoldierProceduralAnimator.StartRagdoll();
|
||||
TimeofDeath = Time.time;
|
||||
MoveDirection = Vector3.zero;
|
||||
foreach (GameObject obj in DisabledOnDeath) {
|
||||
@ -221,11 +228,13 @@ namespace NeonTea.Quakeball.Players {
|
||||
|
||||
/// <summary>Called when this Player is respawned, after dying.</summary>
|
||||
public void Respawn(Vector3 location) {
|
||||
Terminal.Singleton.Println($"Respawned (I am {NetId}), deadness before proper resurrection: {IsDead}");
|
||||
if (Net.Singleton.Instance != null && Net.Singleton.Instance.LocalPlayer.Id == NetId && IsDead) {
|
||||
GameObject.FindGameObjectWithTag("DeadScreen").GetComponent<DeadScreen>().Open = false;
|
||||
Net.Singleton.Instance.LocalPlayer.Controlled.GetComponent<LocalPlayer>().DisableInput -= 1;
|
||||
}
|
||||
transform.position = location;
|
||||
SoldierProceduralAnimator.StopRagdoll();
|
||||
foreach (GameObject obj in DisabledOnDeath) {
|
||||
obj.SetActive(true);
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ PhysicsManager:
|
||||
m_DefaultSolverVelocityIterations: 1
|
||||
m_QueriesHitBackfaces: 0
|
||||
m_QueriesHitTriggers: 1
|
||||
m_EnableAdaptiveForce: 0
|
||||
m_EnableAdaptiveForce: 1
|
||||
m_ClothInterCollisionDistance: 0
|
||||
m_ClothInterCollisionStiffness: 0
|
||||
m_ContactsGeneration: 1
|
||||
m_LayerCollisionMatrix: ffecffffffecffffffecffffffffffffffecffffffecffffffffffffffffffffc8d1ffffc8eaffffffecffffffeeffffc8e1fffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
m_AutoSimulation: 0
|
||||
m_LayerCollisionMatrix: ff6cffffff6cffffff6cffffffffffffff6cffffff6cffffffffffffffffffffc8d1ffffc86affffff6cffffff6effffc861ffffff7effffff7fffffc881ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
m_AutoSimulation: 1
|
||||
m_AutoSyncTransforms: 0
|
||||
m_ReuseCollisionCallbacks: 1
|
||||
m_ClothInterCollisionSettingsToggle: 0
|
||||
|
@ -26,7 +26,7 @@ TagManager:
|
||||
- BloodLayer
|
||||
- Wallbang
|
||||
- PlayerCharacterController
|
||||
-
|
||||
- Ragdoll
|
||||
-
|
||||
-
|
||||
-
|
||||
|
@ -3,7 +3,7 @@
|
||||
--- !u!5 &1
|
||||
TimeManager:
|
||||
m_ObjectHideFlags: 0
|
||||
Fixed Timestep: 0.0333333
|
||||
Fixed Timestep: 0.016
|
||||
Maximum Allowed Timestep: 0.33333334
|
||||
m_TimeScale: 1
|
||||
Maximum Particle Timestep: 0.0333333
|
||||
|
Loading…
Reference in New Issue
Block a user