Game Development Community

MyXnaFps, a bit odd physics?

by Fredrik Dyrwoolf · in · 10/19/2008 (4:57 am) · 8 replies

Hi,
I have completed chapter 12 in Your exelent book, but It seams to be somthing strange with the attached physics(I also downloaded the chapter 12 from this forum, to eliminate the posibillity that I have coded wrong). The Player has a very slow fallign speed, it takes him like 5 minutes or so to fall to the ground.
I've tried to increas GravityScale and Mass, and then I get it to fall faster. But then sometimes it falls throw the ground. I have also noticed that when it actually hits the ground, the attached shadow makes it look like its one third of the players size above the ground.

This is also the same with Your uploaded code.

Sins
Fredrik

#1
10/20/2008 (8:31 pm)
For the first question, the values were intentionally set to be low so that when the game runs, you can see the object falling. The first version of the code had the player already out of sight by the time the game window opened. You should be able to set the GravityScale and Mass higher for a faster fall.

If the player is falling through the terrain, it's probably because it has a square bounding box and is hitting the terrain on a slope. Although I used a square collision box to simplify the example, a sphere collision shape is a lot better for objects moving along a terrain slope. Try using the CollisionSphereShape and set it's center offset as needed.

As for the shadow - in all honesty, it's not much of a shadow. It's just a round blob shadow that doesn't change in size at all. I have plans to create a better shadow rendering shader, but that's still in the works. For now, this is all that's there.

Hope this helps.

John K.
#2
10/20/2008 (10:56 pm)
Thx alot for the answers.
#3
10/21/2008 (10:27 am)
What would be a good GravityScale and Mass for this object?
I'm testing my way forward, but my changes is purly speculating.
Is there any "road marks" to it? Like u should try to have the GravityScale x 10 of the mass for a object that weight around xx kg in a scen of this and X times X size etc?
#4
10/23/2008 (11:59 pm)
Quote:Try using the CollisionSphereShape and set it's center offset as needed.

Even with componentPhysics.CollisionBody.AddCollisionShape(new CollisionSphereShape()); the player is falling through the terrain, so how can I set it's center offset as needed?
#5
10/26/2008 (8:48 am)
Here is a video that shows how the player is falling through the terrain.

www.youtube.com/watch?v=Yl6H1gIifyw
#6
10/26/2008 (8:19 pm)
I watched your video you made. I have noticed that when u pass a certain point on that terrain, u can see it at around 8 seconds, there's a dark line and the texture pretty much disappears. After that point, there is absolutely no collision. I have walked slowly to that point and fallen right through. Try slowing your player speed down alot more and increase the gravity scale. Mine is set at 100 gravity and 40.5 movespeed. Try that out, it seems to work nice for me, except the whole floating thing.
#7
10/27/2008 (5:41 am)
Thank you, Mike.
These values seem to work fine for a walking player though I was trying to implement a faster, flying object like a hoovercraft.
#8
10/30/2008 (10:55 am)
The following code can be used to add a two sphere type collision to boombot. Note that the center of the sphere is offset with the collision.Center line. This is from an older example shared with me from JohnK.

//add a 'snowman' collision shape (two sphere)
CollisionSphereShape collision = new CollisionSphereShape();
collision.Radius = 0.65f;
collision.Center = new Vector3(0.0f, -0.2f, 0.65f);
componentPhysics.CollisionBody.AddCollisionShape(collision);

collision = new CollisionSphereShape();
collision.Radius = 0.75f;
collision.Center = new Vector3(0.0f, 0.0f, 1.95f);
componentPhysics.CollisionBody.AddCollisionShape(collision);