Quantcast
Channel: Questions in topic: "ragdoll"
Viewing all articles
Browse latest Browse all 565

Ragdoll Raycast to Collision

$
0
0
Hello I have a script where when you click a ragdoll it will fall down, now I want the same effect but when an item tagged as "Collider" hits the ragdoll.. Im unable to figure out how to call the ImpactTarget and Direction based off an item with a differnt script 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(); 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; } } }

Viewing all articles
Browse latest Browse all 565

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>