Example #1
0
        public ContactPoint[] IsColliding(Transform at, Transform bt, BoundSphere other)
        {
            Vector3 dir = (at.position - bt.position);

            if (dir.Length() < this.radius + other.radius)
            {
                return new ContactPoint[] { new ContactPoint {
                                                position = Maths.Average(at.position, bt.position), normal = dir,
                                                bodyA    = this.root, bodyB = other.root
                                            } }
            }
            ;

            return(new ContactPoint[0]);
        }
Example #2
0
        public ContactPoint[] IsColliding(Transform at, Transform bt, BoundSphere other)
        {
            Vector3 relpos  = bt.position - at.position - offset;
            Vector3 closest = Maths.Clamp(relpos, radii * -1, radii);

            if ((relpos - closest).Length() < other.radius)
            {
                return new ContactPoint[] { new ContactPoint {
                                                position = (relpos / 2) + at.position,
                                                normal   = Vector3.Normalize(closest),
                                                bodyA    = (RigidbodyHandle)this.root, bodyB = (RigidbodyHandle)other.root
                                            } }
            }
            ;

            return(new ContactPoint[0]);
        }