Jump to content

[3.0] Ball Not Falling


gamecreator
 Share

Recommended Posts

Simple question: why does a ball not fall when set up like this?

 

ballmodel=Model::Load("Models/ball.mdl");
shape=Shape::Load("Models/ball.phy");
ballmodel->SetShape(shape);
ballmodel->SetPosition(0,3,0);
ballmodel->SetMass(1);
ballmodel->SetCollisionType(1);

 

If I get rid of the two shape lines it does fall (but then it also falls through my floor).

 

I've tried generating the shape as both Convex Hull and Polymesh. By the way, why use one instead of the other?

 

screenshot.jpg

Link to comment
Share on other sites

A model already takes the phy file in to account and does not have to be se manually. (as far as I know)

 

How did you set up the floor? Have you set a collision type in the editor via code?

 

 

Convex hulls have no inward vertices and represent a simple shape to enclose the object (not the same as AABB). I believe polymeshes are the same thing as concave meshes. Convex hulls are easier for the physics engine to handle or concave meshes require a more complex calculation by the physics engine.

post-45-0-21371900-1393865222.jpg

Link to comment
Share on other sites

I figured the shape would be loaded automatically (like it did in LE2) so I'm happy to get rid of those lines if that's the way to go.

 

The ground is set up exactly the same way. I'm sure the collision works fine as when I create a box dynamically using your code, here

http://www.leadwerks.com/werkspace/page/tutorials/_/introduction-to-android-r40

it works and bounces off the ground. But the ground also does the same thing: if I don't load the shape manually it falls, whether or not I set SetMass(0);

 

And your explanation on Convex Hulls makes sense. Thank you. My ground has columns to bump against and the collision only worked properly with Polymesh.

 

I'll upload my project when I'm home if there's no solution to this but there's gotta be something simple I'm missing.

Link to comment
Share on other sites

You forgot to set the PhysicsMode. I think you can also release the shape after setting it to save a bit memory.

 

ballmodel=Model::Load("Models/ball.mdl");
ballmodel->SetPosition(0,3,0);
ballmodel->SetPhysicsMode(Entity::RigidBodyPhysics);
ballmodel->SetMass(1);
ballmodel->SetCollisionType(1);
shape=Shape::Load("Models/ball.phy");
ballmodel->SetShape(shape);
shape->Release();

 

Hope that helps.

Link to comment
Share on other sites

So good thought but the SetPhysicsMode wasn't necessary. What was necessary was to set the ball to ConvexHull, not Polymesh (seems like I said I tried this in the original post but apparently not). Otherwise it wouldn't fall. It also seems that loading the PHY files yourself is also necessary (though the documentation doesn't do it here).

 

Here's the project:

https://www.mediafire.com/?ifbf4eyeee3obg1

 

If you press the spacebar it will dynamically generate a falling sphere without loading a model (mostly copied from Aggror's code).

Link to comment
Share on other sites

I create bullets that collides at runtime : they work and are prefabs.

They are simple 3D model spheres without no physhape : i just put in collision tab panel :

shape = sphere

type = prop

mass = 0.2

 

If you do like that and make it a prefab and load it it will work.

 

Perhaps it's a bug with Physhape loading ?

Stop toying and make games

Link to comment
Share on other sites

Next step was to rotate the floor but I can't figure that out either. It seems like if I set the mass to 0 so the floor won't move then it also won't rotate. If I set it to 1 then it falls. Ok, so I use PhysicsSetPosition to keep it in place. But then I have to set the mass to some large number so ball won't just push it around. Fair enough. Then I try to use the following code:

 

if(window->KeyDown(Key:))
 levelmodel->PhysicsSetRotation(-1000,0,0,0.1f);
if(window->KeyDown(Key:))
 levelmodel->PhysicsSetRotation(1000,0,0,0.1f);

 

But that doesn't seem to work on Polymeshes, only Convex Hulls (which isn't what I need). I need to use a Polymesh because my model has columns so it's not convex.

 

Thoughts?

 

Screenshot to better give you an idea of what I'm working with:

screenshot.jpg

Link to comment
Share on other sites

I even tried that style of game in LE3 for someone also trying t do this game type and we had also some issues (old thread)

 

You should keep level as static no rotation, no move.

And fake level rotation or move, by rotating camera only and applying forces to the ball function of camera angles.

Stop toying and make games

Link to comment
Share on other sites

This is either a bug or my lack of understanding on how things work. I'd love for Josh to weigh in on which it is. If it's a bug, I'm happy to put a clearer, thorough report in the bug forum.

 

In either case, both Convex and Poly should be able to be controlled with the very basics: moved or not moved and rotated.

Link to comment
Share on other sites

PolyMesh is for non-moving meshes only (eg static level geometry). ConvexHull should work, but obviously you won't have any concave elements.

 

What needs to happen (and I believe Josh said he would be re-implementing it) is to be able to use Convex Decomposition. What this does is take a concave mesh, break it apart into multiple optimized convex elements, and then use those pieces with Newton's ability to combine multiple shapes for one object.

 

For now, I THINK, you'd have to break your column elements into separate objects and link them to the parent floor...

--"There is no spoon"

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