• Home
  • Products
    • Game Engine
      • Base
      • Mathematics
      • Geometry
      • Physics
      • Particles
      • Animation
      • Graphics
      • Game
      • Game UI
    • Windows Forms
      • Docking Windows
      • Text Editor Control
  • Downloads
  • Buy
    • Overview
    • Professional
    • Indie
    • Non-Commercial
  • Support
    • Overview
    • Blog
    • Forum
    • License FAQ
    • Documentation
  • About
    • About Us
      • Services
    • Contact Us
    • Press
    • Legal Terms
      • Imprint (English)
      • Imprint (German)
Select the search type
 
  • Site
  • Web
Search
DigitalRune.com
Login |Register
NEWS News RSS Feed BLOG Blog RSS Feed FORUM News RSS Feed DOCUMENTATION DigitalRune Software on YouTube DigitalRune Software on Twitter
You are here: SupportForum

If you want to contribute to the forum discussions, please Register or Login.

SearchHome
  • 1
  • 2
  • 3
  • 4
  • 5
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame Engineno collision kinematic vs. static after updateno collision kinematic vs. static after update
Previous
 
Next
New Post
12/28/2011 12:10 AM
 
Laurentius
No Ranking

Joined: 7/30/2011
Posts: 64
no collision kinematic vs. static after update 

In my game I use a kinematic sphere shape for a projectile like spell which worked flawlessly.

Now after changing to the latest DigitalRune library version (DigitalRune.Physics 1.2.0.0 -> 1.3.0.0) I have the problem that there are no collisions with static collision shapes with this kinematic sphere.

The other collision objects work ok (e.g. kinematic sphere -> character controller or static box -> character controller) - so did you change something for kinematic vs. static collsion detection?

If I set the sphere to dynamic the collisions are ok.

 
New Post
12/28/2011 8:42 AM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: no collision kinematic vs. static after update 

Yes, there was a change. (We also summarize such changes in the Change History sections of the documentation.)

The collision detection does still detect the collisions and you can query this information using the CollisionDomain of the Simulation. But the simulation does not create contact constraints anymore. (Contact constraints between non-dynamic objects are superfluous because the simulation must not apply constraint impulses to kinematic or static bodies.)

 
New Post
12/28/2011 10:45 AM
 
Laurentius
No Ranking

Joined: 7/30/2011
Posts: 64
Re: no collision kinematic vs. static after update 

Thank you for your nearly instant responce! :-)

So I changed my handling of collisions for my projectiles in the Update of the physicsscene from:

foreach (ContactConstraint cnt in Simulation.ContactConstraints)
{ 
     if (cnt.BodyA.UserData != null || cnt.BodyB.UserData != null) 
     { 
         GameProjectileObject projectileObjA = cnt.BodyA.UserData as GameProjectileObject; 
         GameProjectileObject projectileObjB = cnt.BodyB.UserData as GameProjectileObject; 
 
         if (projectileObjA != null) 
             projectileObjA.Explode(cnt.BodyB.UserData as GameObject, cnt.LinearConstraintImpulse.ToXna()); 
 
         if (projectileObjB != null) 
             projectileObjB.Explode(cnt.BodyA.UserData as GameObject, cnt.LinearConstraintImpulse.ToXna()); 
     }
} 

to:

foreach (ContactSet cs in Simulation.CollisionDomain.ContactSets)
{ 
     RigidBody bodyA = cs.ObjectA.GeometricObject as RigidBody; 
     RigidBody bodyB = cs.ObjectB.GeometricObject as RigidBody; 
 
     if (bodyA != null && bodyB != null) 
     { 
         if (bodyA.UserData != null || bodyB.UserData != null) 
         { 
             GameProjectileObject projectileObjA = bodyA.UserData as GameProjectileObject; 
             GameProjectileObject projectileObjB = bodyB.UserData as GameProjectileObject; 
 
             if (projectileObjA != null) 
                 projectileObjA.Explode(bodyB.UserData as GameObject, projectileObjA.PhysicsEntity.LinearVelocity.ToXna()); 
 
             if (projectileObjB != null) 
                 projectileObjB.Explode(bodyA.UserData as GameObject, projectileObjB.PhysicsEntity.LinearVelocity.ToXna()); 
 
         } 
     }    
}

It works but I wonder if there is a better solution to respond to collisions and get the corresponding game object? Do I use UserData correctly?

I always had a problem (before and after the update) with projectiles touching my player character controller if the player moves in the same direction as the (hostile) projectile. The projectile was moving faster before it hits the player but when it should hit the player it moves at the same speed as the player and never explodes (looks like stuck at the outer bounds of the character controller shape).

If the player stops moving in the same direction as the projectile the projectile explodes ...

This problem occurs only if the linear speed difference between the char controller and the sphere projectile is low.

Do you have any idea what's going on there?

Thanks again for your marvelous support!

Lars

 
New Post
12/28/2011 11:27 AM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: no collision kinematic vs. static after update 
Laurentius wrote:

It works but I wonder if there is a better solution to respond to collisions and get the corresponding game object? Do I use UserData correctly?

Looks OK to me.

Laurentius wrote:

I always had a problem (before and after the update) with projectiles touching my player character controller if the player moves in the same direction as the (hostile) projectile. The projectile was moving faster before it hits the player but when it should hit the player it moves at the same speed as the player and never explodes (looks like stuck at the outer bounds of the character controller shape).

If the player stops moving in the same direction as the projectile the projectile explodes ...

This problem occurs only if the linear speed difference between the char controller and the sphere projectile is low.

This could be an artifact of motion clamping which is dones as a result of the continuous collision detection (CCD): When a projectile with enabled CCD moves to another object, its movement is cut off when it hits the object to avoid deep penetration or tunneling. It does not move the full distance it could move, instead it only moves to the first time of impact.
The CCD allows some penetration to make sure that the objects really touch at the time of impact.

Following things could happen:

The projectile's motion is clamped but due to some numerical problems, the objects do not touch in the same frame. In the next frame the player moves away. The projectile motion is again clamped, and again the object do not touch. - Given the allowed penetration in the CCD algorithms it seems unlikely that this can happen every frame...

Or maybe the simulation runs and the projectile is clamped. The objects are touching. Then the character controller is updated and moves away from the projectile. If the collision detection is checked after the character controller update, then the projectile collision is missed. The same will repeat in the next frame.

Or something similar.

Solution ideas:

Maybe you have to change something in the update order of the character controller and the physics.
Or, maybe you can disable CCD for the projectile.
Or, maybe use a CCD filter (Simulation.Settings.Motion.CcdFilter) to disable CCD when the speed difference between character and projectile is low.

 
New Post
12/28/2011 1:35 PM
 
Laurentius
No Ranking

Joined: 7/30/2011
Posts: 64
Re: no collision kinematic vs. static after update 

OK ... I managed to work around the problem by settind CcdEnabled only for fast moving projectiles.

Changing the update order of Simulation.Update and the update of the character controllers did not help.

Great! Thanks again! ;-)

 
 Page 1 of 1
Previous
 
Next
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame Engineno collision kinematic vs. static after updateno collision kinematic vs. static after update


DigitalRune is a trademark of Garstenauer Information Technology OG.

Garstenauer Information Technology OG
Weingartenstrasse 35, 4452 Ternberg
Austria (EUROPE)
office@digitalrune.com

Home Products Downloads Buy Support About Us
Game Engine Particles Windows Forms Professional Blog Services
Base Animation Docking Windows Indie Forum Contact Us
Mathematics Graphics Text Editor Control Non-Commercial License FAQ Press (News)
Geometry Game Documentation Legal Terms
Physics Game UI Imprint
Impressum
Copyright © 2006-2012 Garstenauer Information Technology OG Terms Of UsePrivacy Statement