void Start() { if (!NetworkServer.active) { Destroy(this); } ragdoll = GetComponent <HumanRagdoll>(); tileManager = FindObjectOfType <TileManager>(); Assert.IsNotNull(tileManager); origin = tileManager.Origin; }
private void OnCollisionEnter(Collision other) { if (!isServer) { return; } HumanRagdoll humanRagdoll = other.transform.root.gameObject.GetComponent <HumanRagdoll>(); if (humanRagdoll != null && !humanRagdoll.BodyEnabled) { CleanBodyDictionary(); if (!slippedBodies.ContainsKey(humanRagdoll)) { humanRagdoll.KnockDown(knockdownDuration); slippedBodies.Add(humanRagdoll, Time.time); } } }
private void OnCollisionEnter(Collision other) { if (!isServer) { return; } HumanRagdoll humanRagdoll = other.transform.root.gameObject.GetComponent <HumanRagdoll>(); if (humanRagdoll != null && !humanRagdoll.BodyEnabled) { CleanBodyDictionary(); if (!slippedBodies.ContainsKey(humanRagdoll)) { humanRagdoll.BodyEnabled = true; slippedBodies.Add(humanRagdoll, Time.time); StartCoroutine(DisableBodyCoroutine(humanRagdoll)); } } }
// when something touches it private void OnCollisionEnter(Collision other) { if (!isServer) { return; } // tries to get the ragdoll manager in the collision that touched it HumanRagdoll humanRagdoll = other.transform.root.gameObject.GetComponent <HumanRagdoll>(); if (humanRagdoll != null && !humanRagdoll.BodyEnabled) { // Add a threshold for the ragdoll to slip, for example when you use clown shoes you cant slip on bananas CleanBodyDictionary(); if (!slippedBodies.ContainsKey(humanRagdoll)) { humanRagdoll.KnockDown(knockdownDuration); slippedBodies.Add(humanRagdoll, Time.time); } } }
private IEnumerator DisableBodyCoroutine(HumanRagdoll body) { yield return(new WaitForSeconds(3)); body.BodyEnabled = false; }