Beispiel #1
0
        public void SnapAnchorToClosestContact()
        {
            if (!transform.parent)
            {
                return;
            }

            // GetComponentInParent returns enabled/disabled components, need to find enabled one.
            ArticulationBody parentBody = transform.parent.GetComponentInParent <ArticulationBody>();

            while (parentBody && !parentBody.enabled)
            {
                parentBody = parentBody.transform.parent.GetComponentInParent <ArticulationBody>();
            }

            if (!parentBody)
            {
                return;
            }

            Vector3 com = parentBody.worldCenterOfMass;
            Vector3 closestOnSurface = GetClosestPoint(com);

            anchorPosition = transform.InverseTransformPoint(closestOnSurface);
            anchorRotation = Quaternion.FromToRotation(Vector3.right, transform.InverseTransformDirection(com - closestOnSurface).normalized);
        }
Beispiel #2
0
 public void Start()
 {
     #if UNITY_2020_1_OR_NEWER
     unityJoint = GetComponent <UnityEngine.ArticulationBody>();
     #else
     unityJoint = GetComponent <UnityEngine.Joint>();
     #endif
 }
Beispiel #3
0
            // Start is called before the first frame update
            void Start()
            {
                var modelHelpers = GetComponentsInParent(typeof(Model));

                _topModel = (Model)modelHelpers[modelHelpers.Length - 1];

                _artBody = GetComponent <UE.ArticulationBody>();

                // Handle self collision
                if (!isSelfCollide)
                {
                    IgnoreSelfCollision();
                }
            }
    static int get_attachedArticulationBody(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.Collider         obj = (UnityEngine.Collider)o;
            UnityEngine.ArticulationBody ret = obj.attachedArticulationBody;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index attachedArticulationBody on a nil value"));
        }
    }
Beispiel #5
0
            // Start is called before the first frame update
            void Start()
            {
                if (_modelHelper != null)
                {
                    _modelHelper.SetArticulationBody();
                }

                artBody = this.GetComponent <UE.ArticulationBody>();

                // Handle self collision
                if (!isSelfCollide)
                {
                    IgnoreSelfCollision(_modelHelper);
                }
                else
                {
                    EnableSelfCollision();
                }
            }
Beispiel #6
0
        public Joint ExportJointData()
        {
            #if UNITY_2020_1_OR_NEWER
            unityJoint = GetComponent <UnityEngine.ArticulationBody>();
            #else
            unityJoint = GetComponent <UnityEngine.Joint>();
            #endif
            CheckForUrdfCompatibility();

            //Data common to all joints
            Joint joint = new Joint(
                jointName,
                JointType.ToString().ToLower(),
                gameObject.transform.parent.name,
                gameObject.name,
                UrdfOrigin.ExportOriginData(transform));

            joint.limit = ExportLimitData();
            return(ExportSpecificJointData(joint));
        }