public void TurnOnRagdoll() { // this.gameObject.GetComponent<BoxCollider>().enabled = false; RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = true; Rigidbody.useGravity = false; Rigidbody.isKinematic = true; // Animator.enabled = false; // CharController.enabled = false; CapsuleCollider.isTrigger = true; OnGround = true; Standing = false; if (characterType == CharacterType.Player) { GiveControls = false; } else if (characterType == CharacterType.AI) { GetComponent <AIHelper>().AIMove(false); } Debug.Log("3"); foreach (Collider c in RagdollParts) { c.isTrigger = false; c.attachedRigidbody.velocity = Vector3.zero; } }
private static void _RecursiveLinkTransformsByName(Transform ragdoll, Transform body, Transform bodyMatchTransform, ref Transform ragdollMatchTransform, ref bool foundMatch) { ragdollMatchTransform = null; for (int i = 0; i < ragdoll.childCount; i++) { Transform childAtIndex = FindChildHelper.GetChildAtIndex(ragdoll, i); Transform transforms = FindChildHelper.FindChildByName(childAtIndex.name, body); if (transforms) { childAtIndex.position = transforms.position; childAtIndex.rotation = transforms.rotation; if (!foundMatch && transforms == bodyMatchTransform) { foundMatch = true; ragdollMatchTransform = childAtIndex; } if (!foundMatch) { RagdollHelper._RecursiveLinkTransformsByName(childAtIndex, transforms, bodyMatchTransform, ref ragdollMatchTransform, ref foundMatch); } else { RagdollHelper._RecursiveLinkTransformsByName(childAtIndex, transforms); } } } }
protected void Update() { m_time += Time.deltaTime; if (m_postProcessHumanRagdoll > 0u) { --m_postProcessHumanRagdoll; if (m_postProcessHumanRagdoll == 0u) { gameObject.AddComponent <ZombieBehavior> (); gameObject.GetComponent <ZombieBehavior> ().initDelay = 8.0f; Destroy(this); } } else if (m_time > 10.0f) { HealthComponent hc = GetComponent <HealthComponent> (); RagdollHelper r = GetComponent <RagdollHelper> (); if (hc.isDead() && r.ragdolled) { if (m_time > 12.0f) { Destroy(gameObject); } else { setCollidersEnabled(false); } } } }
// Use this for initialization void Start() { this.Obstacles = new List <GameObject>(); GameOver = false; this.ragdoll = this.Player.GetComponent <RagdollHelper>(); this.logicAnimator = this.GetComponent <LogicAnimationController>(); this.movePlayer = this.Player.GetComponent <Moving>(); this.animatorController = this.Player.GetComponent <Animator>(); this.InitiateMap(); this.InitiatePlayer(); Time.timeScale = 0; this.InitiatePlayerPref(); string player = PlayerPrefs.GetString(PlayerPrefsString.NAME); if (PlayerPrefs.GetString(PlayerPrefsString.NAME) != "") { this.StartGame(); } else { ui.EnablePlayerWriteName(); } }
public void DeactivateRagdolling() { //Pressing space makes the character get up, assuming that the character root has //a RagdollHelper script RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = false; }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "target") { RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = true; timestart = true; } }
private void GetAllComponets() { PathGenerator = GetComponent <PathGenerator>(); NavAgent = GetComponent <NavMeshAgent>(); Obstacle = GetComponent <NavMeshObstacle>(); Animator = GetComponent <Animator>(); damageableManager = GetComponent <DamageableManager>(); ragdoll = GetComponent <RagdollHelper>(); animatorHelper = GetComponent <AnimatorHelper>(); }
// Update is called once per frame void Update() { //if left mouse button clicked // if (Input.GetMouseButtonDown(0)) // { // //Get a ray going from the camera through the mouse cursor // Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // // //check if the ray hits a physic collider // RaycastHit hit; //a local variable that will receive the hit info from the Raycast call below // if (Physics.Raycast(ray,out hit)) // { // //check if the raycast target has a rigid body (belongs to the ragdoll) // if (hit.rigidbody!=null) // { // //find the RagdollHelper component and activate ragdolling // RagdollHelper helper=GetComponent<RagdollHelper>(); // helper.ragdolled=true; // // //set the impact target to whatever the ray hit // impactTarget = hit.rigidbody; // // //impact direction also according to the ray // impact = ray.direction * 2.0f; // // //the impact will be reapplied for the next 250ms // //to make the connected objects follow even though the simulated body joints // //might stretch // impactEndTime=Time.time+0.25f; // } // } // } //Pressing space makes the character get up, assuming that the character root has //a RagdollHelper script if (Input.GetKeyDown(KeyCode.B) || timedown >= 5.0f || Z_gamewin.win) { RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = false; timedown = 0; timestart = false; } if (timestart) { timedown += Time.deltaTime; } //Check if we need to apply an impact // if (Time.time<impactEndTime) // { // impactTarget.AddForce(impact,ForceMode.VelocityChange); // } }
public void Die(Vector2 forceToAddToRagdoll) { RagdollHelper.CreateCollidersForRagdoll(transform.position); var ragdoll = Instantiate(PlayerRagdoll, transform.position, transform.rotation); ragdoll.transform.localScale = transform.localScale; ragdoll.CopyPose(PlayerRig); ragdoll.AddForce(forceToAddToRagdoll); Time.timeScale = 0.5f; OnDieEvent.Invoke(); GameObject.Destroy(this.gameObject); }
protected void Awake() { _navMeshAgent = this.GetComponent <NavMeshAgent>(); _characterController = this.GetComponent <CharacterController>(); _animator = this.GetComponent <Animator>(); _footIKController = this.GetComponent <FootIKController>(); _headIKController = this.GetComponent <HeadIKController>(); _handIKController = this.GetComponent <HandIKController>(); _ragdollHelper = this.GetComponent <RagdollHelper>(); _navMeshAgent.updatePosition = false; _navMeshAgent.updateRotation = false; }
private void enableRagdoll(bool enabled) { if (!dead) { RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = enabled; capsul.enabled = !enabled; agent.enabled = !enabled; //anim.enabled = !enabled; fbbik.enabled = !enabled; box.enabled = !enabled; } }
private static void _RecursiveLinkTransformsByName(Transform ragdoll, Transform body) { for (int i = 0; i < ragdoll.childCount; i++) { Transform childAtIndex = FindChildHelper.GetChildAtIndex(ragdoll, i); Transform transforms = FindChildHelper.FindChildByName(childAtIndex.name, body); if (transforms) { childAtIndex.position = transforms.position; childAtIndex.rotation = transforms.rotation; } RagdollHelper._RecursiveLinkTransformsByName(childAtIndex, body); } }
//public Animator animator; //public Rigidbody topLevelRigidBody; //Rigidbody[] rbs; // Use this for initialization void Start() { /*rbs = GetComponentsInChildren<Rigidbody>(); * foreach (Rigidbody rb in rbs) * { * rb.isKinematic = true; * * } * topLevelRigidBody.isKinematic = false;*/ //Get all the rigid bodies that belong to the ragdoll //Add the RagdollPartScript to all the gameobjects that also have the a rigid body helper = GetComponent <RagdollHelper>(); }
// Use this for initialization void Start() { helper = GetComponent <RagdollHelper>(); //Get all the rigid bodies that belong to the ragdoll Rigidbody[] rigidBodies = GetComponentsInChildren <Rigidbody>(); //Add the RagdollPartScript to all the gameobjects that also have the a rigid body foreach (Rigidbody body in rigidBodies) { RagdollPartScript rps = body.gameObject.AddComponent <RagdollPartScript>(); //Set the scripts mainScript reference so that it can access //the score and scoreTextTemplate member variables above rps.mainScript = this; } }
// Update is called once per frame void Update() { //if left mouse button clicked if (GameObject.Find("Player/PlayerRig").GetComponent <ccDeath>().ragdollMe == true) { ////Get a ray going from the camera through the mouse cursor //Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); ////check if the ray hits a physic collider //RaycastHit hit; //a local variable that will receive the hit info from the Raycast call below //if (Physics.Raycast(ray,out hit)) //{ // //check if the raycast target has a rigid body (belongs to the ragdoll) // if (hit.rigidbody!=null) // { //find the RagdollHelper component and activate ragdolling RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = true; ////set the impact target to whatever the ray hit //impactTarget = hit.rigidbody; ////impact direction also according to the ray //impact = ray.direction * 2.0f; //the impact will be reapplied for the next 250ms //to make the connected objects follow even though the simulated body joints //might stretch impactEndTime = Time.time /*+0.25f*/; // } //} } //Pressing space makes the character get up, assuming that the character root has //a RagdollHelper script if (GameObject.Find("Player/PlayerRig").GetComponent <ccDeath>().ragdollMe == false) { RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = false; } //Check if we need to apply an impact if (Time.time < impactEndTime) { impactTarget.AddForce(impact /*,ForceMode.VelocityChange*/); } }
void Start() { agent = GetComponent <UnityEngine.AI.NavMeshAgent>(); anim = GetComponent <Animator>(); //agent = GetComponent<NavMeshAgent>(); // Don’t update position automatically // agent.updatePosition = false; rb = GetComponent <Rigidbody>(); rdh = GetComponent <RagdollHelper>(); // Disabling auto-braking allows for continuous movement // between points (ie, the agent doesn't slow down as it // approaches a destination point). agent.autoBraking = false; GotoNextPoint(); }
void reanimate() { HealthComponent health = GetComponent<HealthComponent> (); health.reanimate (); tag = "Zombie"; this.gameObject.name = "Zombie" + (GameObject.FindGameObjectsWithTag("Zombie").Length).ToString(); //this.gameObject.transform.parent = GameObject.Find("ZombieParent").transform; speedMultiplier = Random.Range (0.5f, 2.5f); UnityEngine.AI.NavMeshAgent n = GetComponent<UnityEngine.AI.NavMeshAgent>(); Animator a = GetComponent<Animator>(); RagdollHelper r = GetComponent<RagdollHelper> (); if (n != null && a != null && r != null) { n.enabled = true; n.SetDestination (this.transform.position); } }
public void LinkRagdoll(Transform thisRoot, GameObject ragdoll) { Transform transforms; if (!this.exists) { RagdollHelper.RecursiveLinkTransformsByName(ragdoll.transform, thisRoot); } else if (RagdollHelper.RecursiveLinkTransformsByName(ragdoll.transform, thisRoot, this.transform, out transforms)) { Transform transforms1 = transforms; Rigidbody rigidbody = transforms1.rigidbody; if (rigidbody) { Vector3 vector3 = transforms1.TransformPoint(this.localPoint); Vector3 vector31 = transforms1.TransformDirection(this.localNormal); rigidbody.AddForceAtPosition(vector31 * 1000f, vector3); } } }
void updateInitBehaviour() { if (initDelay == 0.0f) { m_state = State.Spawning; return; } if (m_stateTime >= initDelay / 2 ) { RagdollHelper r = GetComponent<RagdollHelper> (); if (r != null) { r.ragdolled = false; } } if( m_stateTime >= initDelay ) { reanimate(); m_state = State.Spawning; } }
public void ActivateRagdolling(Rigidbody impactTarget, Vector3 force) { Transform pointer = impactTarget.transform; while (!pointer.GetComponent <RagdollHelper>() && pointer.parent != null) { pointer = pointer.parent; } if (!pointer.GetComponent <RagdollHelper>()) { return; } else { //find the RagdollHelper component and activate ragdolling RagdollHelper helper = pointer.GetComponent <RagdollHelper>(); helper.ragdolled = true; impactTarget.AddForce(force, ForceMode.Impulse); } }
public void TurnOffRagdoll() { // this.gameObject.GetComponent<BoxCollider>().enabled = false; RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = false; // Animator.enabled = true; // Animator.Rebind(); OnGround = false; Standing = true; Rigidbody.useGravity = true; Rigidbody.isKinematic = false; foreach (Collider c in RagdollParts) { c.isTrigger = true; c.attachedRigidbody.velocity = Vector3.zero; } // CharController.enabled = true; CapsuleCollider.isTrigger = false; // Debug.Log("3"); }
public override void Reset() { base.Reset(); if (!animatedRagdollCharakter) { animatedRagdollCharakter = GetComponent <RagdollHelper>(); } player = FindObjectOfType <vp_PlayerDamageHandler>(); Randomize(); animatedRagdollCharakter.ragdolled = false; ragdolled = false; currentUpwardsVelocity = 0.0f; animatedRagdollCharakter.setKinematic(true); if (!agent) { agent = GetComponent <NavMeshAgent>(); } if (!animator) { animator = GetComponent <Animator>(); } //agent.enabled = true; animator.enabled = true; agent.updateRotation = false; targetPos = transform.position; animator.SetTrigger("WakeUp"); StartCoroutine(UpdatePath()); }
public void LinkRagdoll(Transform thisRoot, GameObject ragdoll) { if (this.exists) { Transform transform; if (RagdollHelper.RecursiveLinkTransformsByName(ragdoll.transform, thisRoot, this.transform, out transform)) { Transform transform2 = transform; Rigidbody rigidbody = transform2.rigidbody; if (rigidbody != null) { Vector3 position = transform2.TransformPoint(this.localPoint); Vector3 vector2 = transform2.TransformDirection(this.localNormal); rigidbody.AddForceAtPosition((Vector3)(vector2 * 1000f), position); } } } else { RagdollHelper.RecursiveLinkTransformsByName(ragdoll.transform, thisRoot); } }
public bool turnIntoRagdoll() { UnityEngine.AI.NavMeshAgent n = GetComponent <UnityEngine.AI.NavMeshAgent>(); Animator a = GetComponent <Animator>(); HumanBehavior h = GetComponent <HumanBehavior>(); ZombieBehavior z = GetComponent <ZombieBehavior>(); RagdollHelper r = GetComponent <RagdollHelper> (); HealthComponent hc = GetComponent <HealthComponent>(); setCollidersEnabled(true); bool result = false; if (n != null && a != null && r != null && a.enabled) { r.ragdolled = true; m_time = 0.0f; if (h != null) { h.die(); if (!hc.wasKilledBy(null)) { m_postProcessHumanRagdoll = 1u; } result = true; } else if (z != null) { if (hc.isDead()) { z.die(); } result = true; } n.enabled = false; } return(result); }
public static void RecursiveLinkTransformsByName(Transform ragdoll, Transform body) { BoneStructure component = body.GetComponent <BoneStructure>(); if (component) { BoneStructure boneStructures = ragdoll.GetComponent <BoneStructure>(); if (boneStructures) { BoneStructure.ParentDownOrdered.Enumerator enumerator = component.parentDown.GetEnumerator(); try { BoneStructure.ParentDownOrdered.Enumerator enumerator1 = boneStructures.parentDown.GetEnumerator(); try { while (enumerator.MoveNext() && enumerator1.MoveNext()) { Transform current = enumerator.Current; Transform transforms = enumerator1.Current; transforms.position = current.position; transforms.rotation = current.rotation; } } finally { ((IDisposable)(object)enumerator1).Dispose(); } } finally { ((IDisposable)(object)enumerator).Dispose(); } return; } } RagdollHelper._RecursiveLinkTransformsByName(ragdoll, body); }
public void Set(ulong _identity, string _prefab) { identity = _identity; prefab = _prefab; animator = GetComponent <SNet_Animator>(); rbody = GetComponent <SNet_Rigidbody>(); tform = GetComponent <SNet_Transform>(); controller = GetComponent <SNet_Controller>(); ragdoll = GetComponent <RagdollHelper>(); explosive = GetComponent <Explosive>(); vehicle = GetComponent <SNet_Vehicle>(); asource = GetComponent <AudioSource>(); if (_identity < 1000000 && identity > SNet_Network.SNetMessage.idStep) { SNet_Network.SNetMessage.idStep = identity; } /* * MAX REALTIME NETWORK OBJECTS LIMIT is 1.000.000 * */ set = true; }
public static bool RecursiveLinkTransformsByName(Transform ragdoll, Transform body, Transform bodyMatchTransform, out Transform ragdollMatchTransform) { bool flag; if (!bodyMatchTransform) { ragdollMatchTransform = null; RagdollHelper.RecursiveLinkTransformsByName(ragdoll, body); return(false); } if (body == bodyMatchTransform) { ragdollMatchTransform = ragdoll; RagdollHelper.RecursiveLinkTransformsByName(ragdoll, body); return(true); } BoneStructure component = body.GetComponent <BoneStructure>(); if (component) { BoneStructure boneStructures = ragdoll.GetComponent <BoneStructure>(); if (boneStructures) { BoneStructure.ParentDownOrdered.Enumerator enumerator = component.parentDown.GetEnumerator(); try { BoneStructure.ParentDownOrdered.Enumerator enumerator1 = boneStructures.parentDown.GetEnumerator(); try { while (enumerator.MoveNext() && enumerator1.MoveNext()) { Transform current = enumerator.Current; Transform transforms = enumerator1.Current; transforms.position = current.position; transforms.rotation = current.rotation; if (current != bodyMatchTransform) { continue; } ragdollMatchTransform = transforms; while (enumerator.MoveNext() && enumerator1.MoveNext()) { current = enumerator.Current; transforms = enumerator1.Current; transforms.position = current.position; transforms.rotation = current.rotation; } flag = true; return(flag); } } finally { ((IDisposable)(object)enumerator1).Dispose(); } ragdollMatchTransform = null; return(false); } finally { ((IDisposable)(object)enumerator).Dispose(); } return(flag); } } bool flag1 = false; ragdollMatchTransform = null; RagdollHelper._RecursiveLinkTransformsByName(ragdoll, body, bodyMatchTransform, ref ragdollMatchTransform, ref flag1); return(flag1); }
void ManageEnemyHit(RaycastHit hit, Ray ray) { //find the RagdollHelper component and activate ragdolling RagdollHelper helper = hit.collider.GetComponentInParent <RagdollHelper> (); StairDismount stDis = hit.collider.GetComponentInParent <StairDismount> (); Enemy enemyHit = hit.collider.gameObject.GetComponentInParent <Enemy> (); if (!enemyHit.isTank) { helper.ragdolled = true; enemyHit.reticleCanvas.SetActive(false); if (!enemyHit.isDead) { if (enemyHit.order == 0) { GameManager.instance.EnemyDied(); } } enemyHit.isDead = true; //set the impact target to whatever the ray hit stDis.impactTarget = hit.rigidbody; //impact direction also according to the ray stDis.impact = ray.direction * 2.0f; //the impact will be reapplied for the next 250ms //to make the connected objects follow even though the simulated body joints //might stretch stDis.impactEndTime = Time.time + 0.25f; //Show a hit marker where the enemy was shot Destroy(Instantiate(hitMarker, hit.point, Quaternion.identity), 2); //Show an headshot icon when the player hits the enemy's head if (hit.collider.tag == "Face") { Destroy(Instantiate(headshotIcon, hit.point, Quaternion.identity), 2); } } else { enemyHit.tankHealth -= 1; enemyHit.healthSlider.value = enemyHit.tankHealth; if (enemyHit.tankHealth <= 0) { helper.ragdolled = true; enemyHit.reticleCanvas.SetActive(false); if (!enemyHit.isDead) { if (enemyHit.order == 0) { GameManager.instance.EnemyDied(); } } enemyHit.isDead = true; //set the impact target to whatever the ray hit stDis.impactTarget = hit.rigidbody; //impact direction also according to the ray stDis.impact = ray.direction * 2.0f; //the impact will be reapplied for the next 250ms //to make the connected objects follow even though the simulated body joints //might stretch stDis.impactEndTime = Time.time + 0.25f; if (hit.collider.tag == "Face") { Destroy(Instantiate(headshotIcon, hit.point, Quaternion.identity), 2); } } Destroy(Instantiate(hitMarker, hit.point, Quaternion.identity), 2); } }
// Use this for initialization void Start() { ragdoll = GetComponentInParent <RagdollHelper> (); }
void Update() { healthSlider.value = healthE; if (healthSlider.value >= lookHealth || healthSlider.value <= 0) { healthSlider.gameObject.SetActive(false); } else { healthSlider.gameObject.SetActive(true); } Vector2 screenPoint = RectTransformUtility.WorldToScreenPoint(Camera.main, transform.position); healthTrans.transform.position = screenPoint; if (deal) { anim.SetBool("SpecialDamage1", true); rot.enabled = false; rot2.enabled = false; GetComponent <FullBodyBipedIK>().enabled = false; GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = false; GetComponent <EnemyMili>().enabled = false; } if (dealDead) { healthE -= 300; } if (dealDamage) { if (substractOnce == false) { healthE -= 20; substractOnce = true; anim.SetTrigger("Hit"); } StartCoroutine("CloseDamage"); } if (healthE <= 0) { if (!dead) { //for(int i = 0; i<items.Length; i++) //{ // items[i].parent = null; // items[i].GetComponent<Rigidbody>().isKinematic = false; //} if (GetComponent <EnemyMili>()) { capsul.GetComponent <CapsuleCollider>().enabled = false; box.GetComponentInChildren <BoxCollider>().enabled = false; GetComponent <EnemyMili>().enabled = false; anim.enabled = false; rot.enabled = false; rot2.enabled = false; RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = true; GetComponent <RagdollHelper>().enabled = false; GetComponent <FullBodyBipedIK>().enabled = false; GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = false; // Destroy(gameObject, 5f); } if (GetComponent <EnemyRobotAI>()) { capsul.GetComponent <CapsuleCollider>().enabled = false; box.GetComponentInChildren <BoxCollider>().enabled = false; GetComponent <EnemyRobotAI>().enabled = false; anim.enabled = false; RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = true; GetComponent <RagdollHelper>().enabled = false; GetComponent <FullBodyBipedIK>().enabled = false; GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = false; deadrobots = true; } if (GetComponent <EnemyRobotAISpawn>()) { capsul.GetComponent <CapsuleCollider>().enabled = false; box.GetComponentInChildren <BoxCollider>().enabled = false; GetComponent <EnemyRobotAISpawn>().enabled = false; anim.enabled = false; RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = true; GetComponent <RagdollHelper>().enabled = false; GetComponent <FullBodyBipedIK>().enabled = false; GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = false; } //if (GetComponent<EnemyAI>()) //{ // anim.enabled = false; // GetComponent<EnemyAI>().enabled = false; // GetComponent<UnityEngine.AI.NavMeshAgent>().enabled = false; //// Destroy(gameObject, 5f); //} if (GetComponent <EnemyShootAi>()) { RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = true; anim.enabled = false; GetComponent <EnemyShootAi>().enabled = false; GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = false; // Destroy(gameObject, 5f); } if (GetComponent <Boss>()) { capsul.GetComponent <CapsuleCollider>().enabled = false; box.GetComponentInChildren <BoxCollider>().enabled = false; GetComponent <Boss>().enabled = false; anim.enabled = false; RagdollHelper helper = GetComponent <RagdollHelper>(); helper.ragdolled = true; GetComponent <RagdollHelper>().enabled = false; GetComponent <FullBodyBipedIK>().enabled = false; GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = false; dark.enabled = true; // Destroy(gameObject, 5f); } dead = true; } } if (ragdoll_state == true) { ragdoll_time -= Time.deltaTime; } if (ragdoll_time < 0 && ragdoll_state == true) { ragdoll_func_off(); ragdoll_time = 1.5f; } }