Jump to content

How to scale physics shape in C+++


Arkane
 Share

Recommended Posts

Hi,

 

I'm trying to resize the physics shape of a cylinder which is my player.

 

I've tried a simple code :

 

Entity* player;
Model* playerModel;

//Create the player
player = Pivot::Create();
player->SetPhysicsMode(Entity::CharacterPhysics); // Set player physics
player->SetPosition(Vec3(0, 1, 0));
player->SetMass(1);

//Create player mesh
playerModel = Model::Cylinder(64);
playerModel->SetParent(player);
playerModel->SetPosition(Vec3(0, 4, 0));
playerModel->SetScale(1, 2, 1);
playerModel->SetColor(0.0, 1.0, 0.0);
Shape* playerShape = Shape::Cylinder(0, 0, 0, 0, 0, 0, 2, 1, 1);
playerModel->SetShape(playerShape);
playerShape->Release();

 

What I'm doing wrong ?

 

Thanks

Link to comment
Share on other sites

//Create the player

player = Pivot::Create();

player->SetPosition(0.0,1.309,0.5);

player->SetMass(50);

player->SetPhysicsMode(Entity::CharacterPhysics);

jane.model->SetPosition(player->GetPosition());

 

Heres my similar code . replace jane.model with cylinder.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

The character controller you have on the pivot gives you a cylinder shape for your character. If you have Nother shape and put them in the same location which would put them inside each other they might act badly. Multiple ppl have found the default character controller phyics limiting but otherwise you have to build your own which isn't easy to do well.

Link to comment
Share on other sites

You can't remove the default character controller shape. You would simply not use it. However this means you have to control the physics of a shape that you make to act like the character controller, which isn't an easy task to get right and will most likely end in frustration smile.png.

 

If your models are either clipping through you can either scale things down so they don't or just deal with it. Some will tell you that games like L4D and alike have models clipping and it's not that big of a deal. It's your call on the amount of effort you want vs the benefit you are getting from it.

 

ie. It's not as simple as you're hoping.

Link to comment
Share on other sites

So I will let this part away. I know many games have this issue that is considered as "not a big deal" for model clipping a little bit through "structures".

I was just wondering if it was easily dealing with. But if it's not, no matter ;)

 

I will concentrate my effort on my third person camera collision (other post http://www.leadwerks.com/werkspace/topic/10702-third-person-camera-collision/).

 

Thanks Rick for your help !

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...