Wheels EventManager

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Pedro
Posts: 4
Joined: Thu Oct 07, 2010 10:44 am

Wheels EventManager

Post by Pedro »

Hi, i got some difficulties with the Wheels.
Ok i have a vehicle and i want to know when each wheel have a collision with the ground or not.
Iam using the WheelShape.Detector property.

Code: Select all

for (var k = 0; k < 4; k++)
            {
                Vehicle.Wheels[k].Shape.Detector.Tag = string.Format("Wheel_{0}", k);
                Vehicle.Wheels[k].Shape.Detector.EventManager.InitialCollisionDetected += HandleCollision;
                Vehicle.Wheels[k].Shape.Detector.EventManager.CollisionEnded += HandleEndCollision;
            }
But this code doesn't work :cry:
Thanks for helping...; and sorry for my bad English
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Wheels EventManager

Post by Norbo »

The Detector does not create contacts with anything, so it will never actually fire contact-related events like InitialCollisionDetected or CollisionEnded. It will, however, fire CollisionPair related events.

CollisionPair events won't tell you exactly when the ray hits something, but rather when the Detector's AABB overlaps with other entities' AABB's.

You can also check the Vehicle's support entities each frame through each Wheel's SupportingEntity property.
Pedro
Posts: 4
Joined: Thu Oct 07, 2010 10:44 am

Re: Wheels EventManager

Post by Pedro »

Thanks. i will test the SupportingEntity
Pedro
Posts: 4
Joined: Thu Oct 07, 2010 10:44 am

Re: Wheels EventManager

Post by Pedro »

oops, when i try to use the SupportingEntity in the update method, i get "Object reference not set to an instance of an object."
wheel.SupportingEntity = null

the code is in the update method

Code: Select all

foreach (var wheel in Vehicle.Wheels)
                {
                    wheel.SupportingEntity.EventManager.InitialCollisionDetected += HandleCollision;
                    wheel.SupportingEntity.EventManager.CollisionEnded += HandleEndCollision;
                }
Pedro
Posts: 4
Joined: Thu Oct 07, 2010 10:44 am

Re: Wheels EventManager

Post by Pedro »

Oh, i fixe it.
Its just test if the supportingEntity is null or not "Collision or not"
Thanks Norbo, you are a life saver.
Post Reply