Jump to content

Is a model supposed to fall half way through the ground? (Character Controller phy)


TheConceptBoy
 Share

Recommended Posts

Greetings everyone.

I'm experimenting with C++ at the moment and it seems that the Box model I create via code is falling through the floor half way, I've even tried to attach a shape to it, however that does not seem to affect it in any way. Someone said that if a 3D model is falling through the floor, it needs to have it's x0, y0 and z0 to be at the feet of the chatacter. This is a simple box made in code and it feels as if the collisions with the world are being calculated for a single point, rather than a shape.

 


	Model* player_sphere = Model::Box();
	player_sphere->SetPhysicsMode(Entity::CharacterPhysics);
	player_sphere->SetMass(1);
	player_sphere->SetPosition(0, 10, 0);

	Shape * pl_shape = Shape::Box(0,0,0, 0,0,0, 20,20,20);
	player_sphere->SetShape(pl_shape);

	Camera* camera = Camera::Create(player_sphere);
	camera->Move(0.4, 2.4, -1);

I just want to see if tis is normal behavior. All the ramp, plane and terrain collisions seem to be working ok. I can offset the camera. I just have a feeling that you would normally see the shape not sink half way into the ground as if the collisions are being calculated for the single center point as opposed to a 3D shape.

 

EDIT1:

Now i see that this question has been asked at least once already. Thread 1 and Thread 2 These people have been dealing with the 3D models. For now I just want to find out whether the objects, a simple box, created via C++ API commands, with a character controller for it's physics collision is supposed to be sunk half way in the first place? It seems so weird because, if I set the shape to a cylinder or a sphere, I can see the sides of the spheres colliding with the walls and preventing movement. Why does this also not affect the bottom of the sphere?

 

 

  • Upvote 1
Link to comment
Share on other sites

For this reason, it's best to use a pivot as a character controller and parent anything you'd like to it, like so:

Model* player_sphere = Model::Box();
player_sphere->SetPosition(0, 0.5, 0);

Entity* controller = Pivot::Create();
controller->SetMass(1);
controller->SetPhysicsMode(Entity::CharacterPhysics);
player_sphere->SetParent(controller, true);

Also, it may help you to turn on physics debugging to see what's going on.

camera->SetDebugPhysicsMode(true);

Great job on all the detail you provided, by the way.  It inspired me to jump into Visual Studio to research this.

Link to comment
Share on other sites

3 minutes ago, gamecreator said:

For this reason, it's best to use a pivot as a character controller and parent anything you'd like to it, like so:


Model* player_sphere = Model::Box();
player_sphere->SetPosition(0, 0.5, 0);

Entity* controller = Pivot::Create();
controller->SetMass(1);
controller->SetPhysicsMode(Entity::CharacterPhysics);
player_sphere->SetParent(controller, true);

 

So that's a yes then? This is normal behavior for the character controller? The physics are calculated for a point in space instead of some sort of a volume objects? I take it the shape is meant for rigid bodies only then, not character controllers?

Link to comment
Share on other sites

The entity pivot will be at the very bottom of the physics shape, since character models are usually created with the origin at the feet.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...