Physics

rated by 0 users
This post has 9 Replies | 4 Followers

Top 50 Contributor
Posts 106
SunBurn_Community_Licensee
Jeff Posted: 04-25-2012 11:20 PM

Okay, does anyone know how to use the new built-in physics system?

Top 100 Contributor
Posts 50
SunBurn_Community_Licensee

Hello,

I'm trying to setup a basic collision handling(no physics needed)

Just need to have a trigger when 2 objects collide.

What I'm doing is

 

            BulletObject.CollisionType = CollisionType.Trigger;

            BulletObject.CollisionTriggerEvent += _collisionTriggerEvent;

            BulletObject.HullType = HullType.Box;

 

Now, this does not work as I'm not getting the event fired at all.

probably I'm missing something basic here.

Is there some initialization needed to be done to the PhysicsManager?

all I did was:

SceneInterface.AddManager(new PhysicsManager(SceneInterface));

 

I tried to find an example for a basic collision usage...

Any help Appreciated.

Chen

 

Top 10 Contributor
Posts 6,151
Employee
SunBurn_Pro_Licensee
SunBurn_Studio_Licensee

Hi guys,

Both the Dojo and Light Mapping examples show how to setup and use collision / physics in SunBurn - and also how to spawn objects that are controlled by players.

The setup is relatively easy: make sure to add the SunBurn physics assembly to your project, then use the SceneInterface.CreateDefaultManagers() overload that accepts a collision system type (Physics or LegacyCollision).

You can then set each scene object's collision type to be collideable, to trigger events, or to be ignored by collision / physics (the default).

chenmark:
I'm not getting the event fired at all.

Make sure to move the object(s) using the CollisionMove.ApplyForce() methods, these apply motion to the object and activate it.  Setting the World transform directly bypasses the collision / physics and may not trigger an event (if the object is at rest).

Also make sure the UpdateType for the objects is set to Automatic - this ensures the objects are dynamic and receive events from the engine.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 50 Contributor
Posts 106
SunBurn_Community_Licensee

That's all I needed to know, thanks.

Top 100 Contributor
Posts 50
SunBurn_Community_Licensee

Thanks JohnK

Actually I only need to have collision detection and not a full physics system for my project.

I am making all objects movement through direct World assignments.

In my case I would like to have a bullets collision handler fired.

If there is a built-in collision support for such an approach, Will it be a proper one, as these bullets travels very fast in each frame and probably might skip a collision region at the next frame.

Or do I have to manually calculate the bullet travel for the current frame as a collision box and to run intersection tests for the whole scene graph all manually?

Thanks

Chen

 

 

 

 

 

Top 10 Contributor
Posts 6,151
Employee
SunBurn_Pro_Licensee
SunBurn_Studio_Licensee

Hi Chen,

You can calculate bullet collision using the ICollisionManager.RayCast() methods.  Instead of making the bullet objects themselves collideable, use the RayCast to see if the bullet will hit anything during that frame and either move the bullet to its new location or distribute damage as needed.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 50 Contributor
Posts 106
SunBurn_Community_Licensee

Okay, so how can I do physics while still assigning world transform.  Because, if I don't assigne the worl transform then I can't scale or rotate my entity.  But if I do, physics doesn't work.  I wish there was some kind of MoveTo feature with the new physics system.

Top 10 Contributor
Posts 517
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

You can scale and rotate your model with out moving it, this will just rotate the model:

float angle = (float)gameTime.ElapsedGameTime.TotalSeconds * forceToApply;
Matrix rotation = Matrix.CreateRotationY(angle);
sceneobject.World = rotation * sceneobject.World;

More details on my blog:
http://dsebj.evolvingsoftware.com/2011/04/23/player-movements-in-3d-sunburn-components/

Top 50 Contributor
Posts 106
SunBurn_Community_Licensee

So, as long as I only apply scale and rotation matrixes to the world, I can still use the physics? 

Top 10 Contributor
Posts 517
SunBurn_Community_Licensee
SunBurn_Contributor
SunBurn_Pro_Licensee

Basically, yes.

Page 1 of 1 (10 items) | RSS