Unity3d Physical Rigidbody Prevention interspersed

Source: Internet
Author: User

Unity3d Physical Rigidbody Prevention interspersed

@ Guangzhou Dragon

Unity's physics engine uses the PhysX engine, and the components inside it are rigidbody! that can simulate physical effects!

Rigidbody, this is can be interspersed, if interspersed with more words, there will be unpredictable control!

But Rigidbody has a problem, that is, when interspersed, how to react, in fact, we can use the ray to pre-test!

This is what we are talking about today Physics.raycast to make a pre-judgment!

static bool Raycast (Vector3 origin, Vector3 direction, float distance = mathf.infinity, int layermask = defaultraycastlayers);

This is a static function, belongs to the physics class, Origin is the starting point, direction is the direction, it can be said to be the length, distance is the distance length, Layermask is the layer!

Code: Vector3 fwd = transform. Transformdirection (Vector3.forward);//value in current direction fwd

if (Physics.raycast (Transform.position, Fwd, 10))//If this ray has touched this object, pause it so that it can be prevented from interspersed!

Print ("There is something in front of the object!");

I want to use the code to simulate the actual physical effects!

By animating the animation in the bone, and testing it, then simulating the addforce so that another rigidbody can be physically processed!

Especially in the non-human control problem, Unity3d does not give a certain component to deal with, which requires us to simulate, is the object of the skeletal animation, binding on the bones of the Ray

The code of the detection, at the point of the collision, give another object a force, so that can be effectively interspersed processing!

You are welcome to Exchange qq:1357098586 with me.

                   

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.