Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by JuanseCoello · Apr 12, 2014 at 05:19 AM · raycastcolliderragdollbone

How can I cast a ray from a ragdolls child bone? And disable the rest

I know you can cast a ray from the rigidbody, but if i am using a ragdoll with a lot of rigidbodies and colliders, how can I choose only one part of the armature, lets say the hips(I mean the hips green collider), to check collision with the ground. But only raycast from this bone and disable all the rest of the raycasts?

Like this: alt text

I have this script that raycasts to check if the character is grounded

void IsGrounded() {

     RaycastHit hitInfo;
     if (Physics.Raycast(transform.position + Vector3.up * 0.8f, Vector3.down * 0.5f, out hitInfo, Mathf.Infinity))
      
     {
         if (hitInfo.distance > 0.1f) // Change .1f to what you need
             Debug.DrawRay(transform.position + Vector3.up * 5f, Vector3.down * 5f, Color.green);

             isgrounded = false;

         if (hitInfo.distance < 0.1f)
             isgrounded = true;
     }

 } 
raycast.png (33.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Owen-Reynolds · Apr 12, 2014 at 05:11 PM

Raycasts aren't "from" any particular object. The first input, where they start, is just an xyz, anywhere in space.

In your example, it looks up the player's location and tweaks it a little. But transform.position + Vector3.up * 0.8f is just an xyz. If you increased 0.8, the raycast would kind of be from the head, but really just from where-ever the math said.

If you want the raycast to start from the hips, just look up their position in the usual way, and use that as the first input. If you aren't sure, search around UA for "finding game objects" or "finding children."

To ignore other body parts, a raycast can be made to hit only certain types of things, and ignore the rest. The official name for an object's "type" is a layer. Raycasting and layers also has lots of explanation in UA.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JuanseCoello · Apr 15, 2014 at 01:09 AM 0
Share

That is not totally true, because I used a rigid body with a collider and a raycast, and tested the raycasr, and it is casted from the collider, I mean the ray starts at the border of the collider, it has not an xyz anywhere in space.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Mouse Over Wont Work on Bone Animated Meshes. 1 Answer

Do animations affect the accuracy of a collider? 0 Answers

Raycast occasionally won't hit colliders on Mecanim animated characters (but hits perfectly if Animator is disabled) 1 Answer

Ragdoll Raycast to Collision 0 Answers

Raycast Problem. CharacterJoint/Rigibodies 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges