Jump to content

Newbie question about collision with animated model


PoussinJoyeux
 Share

Recommended Posts

Hi,

 

I'm continuing my LW discovery.

The new question I encounter is this one:

-> If I have an animated model, the physic shape I put on it does not change with the animation (which seems normal from what I've seen).

So what are my options if I want to avoid that other characters don't collide with it?

 

From what I understand, I need to set a basic physic shape that will be big enough to cover all the area used during animation.

Is there a better tuning option? Something which would be more accurate.

 

I can see mentions of hitbox in the forum but I don't understand if it is the other solution?

And if so, to generate it, is it done only by using the code lines like here (or do I need to do something else?):

http://www.leadwerks.com/werkspace/blog/1/entry-1363-say-goodbye-to-hitboxes/

 

Thanks and sorry if my question is too easy! :)

Link to comment
Share on other sites

Create a pivot as a physics controller and attach the character to it.

 

in c++

mycharacter.pivot = Pivot::Create();

 

mycharacter.pivot->SetPosition(-44, 2.9, 22.0);

mycharacter.pivot->SetMass(50);

mycharacter.pivot->SetPhysicsMode(Entity::CharacterPhysics);

mycharacter.model->SetPosition(mycharacter.pivot->GetPosition());

 

Don't worry about the size of the pivot.

 

EDIT:Or have I misssunderstood your question?

  • Upvote 1

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

Hi cassius,

 

First, thanks for your answer!

 

I tried your code but my FPS player still go through the sculpture (even when sculpture is not moving).

Here are some abstracts of my code:

 

 

//Sculpture

Model* sculptureMesh;

Entity* sculpture;

...

 

// Init Sculpture

sculptureMesh = Model::Load("Models/BlenderImport/animation.mdl");

 

sculpture = Pivot::Create();

sculpture->SetPosition(10, 10, 10);

sculpture->SetMass(10);

sculpture->SetPhysicsMode(Entity::CharacterPhysics);

sculptureMesh->SetPosition(sculpture->GetPosition());

 

sculptureMesh->SetParent(sculpture);

 

 

So yes, maybe I was not clear smile.png

 

So what I want is that my FPS player (or other characters) collides with my "sculpture" mesh and does not go through it.

And this "sculpture" is not a simple box/ball and have animation.

 

So if create a convex physic shape, it will only cover the first frame of animation and the only way I've found until now is to set a big physic sphere all around the sculpture but it is not accurate enough and my FPS player is like blocked by invisible walls when he approaches from the sculpture.

Link to comment
Share on other sites

Yes I agree with you but my point is: how can I be sure that my object will correctly manage collisions in all states of its animation?

 

Imagine a guy who keeps his arms close to its body and then raises them at the end of the animation.

So if I set the physic shape to convex decomposition on the first frame then when he raises his arms, his hands will be out of the physic shape (because the shape does not follow animation) and so anybody will go through his hands and will not collide.

 

Am I more clear?

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