- Home /
Sphere, internal collision
I'll preface this by saying I'm a Unity scrub but have decent game programming experience, particularly XNA, GameMaker, and Processing.
I'm working on a game that does something like MonkeyBall where a primary ball is the player except it uses multiple objects in the sphere to determine it's movement.
I'm trying to find a to keep the objects the sphere. I made the meshes in Modo, an internal and external sphere. The internal sphere has the normals flipped to face the center of the sphere.
I tried to use a Mesh Collider but received a "Non-convex MeshColliders with non-kinematic Rigidbodies are no longer supported Unity 5.0." error. I'm not entirely sure what this means. This suggested turning on the convex and trigger fields but that just gave me more errors complaining about the amount of polys my mesh. I'm not sure if I can actually reduce the polys since it is the basic sphere Modo.
Another post I read suggested using the Vector3.Reflect to keep the objects when hitting the outer of the sphere. This be my option but I'm not entirely how I would implement it considering my lack of Unity experience.
I would appreciate any suggestions or pointers.
!
Seems like your question is a bit borked:
"I'm trying to find a to keep the objects the"
"I'm working on a game that does something like $$anonymous$$onkeyBall where a primary is the except it uses multiple objects the to deter$$anonymous$$e it's movement."
That sentence is still messed up...
"a primary is the ..." The what? "it uses multiple objects the to deter$$anonymous$$e ..." another 'the' that doesn't seem to refer to anything...
I'm not familiar with $$anonymous$$onkeyBall, so it's not completely clear what you want. But it sounds like you want an 'inverted sphere collider'?
Hmm, I don't actually know at what point the OnCollisionEnter() and OnCollisionExit() methods get called if the object comes from inside the collider (if they get called at all), but those methods would be my first idea to use. Just invert the forces on colliding objects just after a collision (if those methods get called).
Otherwise, you may have to write your own collision check.
Yeah, sorry, it looks like random words got cut out. I'm now actually unsure if it was my fault. Anyhow, I took a quick look over and fixed what I saw.
$$anonymous$$onkeyball essentially has a character that rolls around in a ball. Think sonic but never running, always rolling.
Answer by Baste · May 03, 2015 at 10:41 PM
The issue with non-convex colliders with rigidbodies is a drawback to the physics engine. You only really run into it when you're trying to do things that essentially boild down to "hamster wheels" - all physics objects needs to be convex - which means that there has to be a closed surface in every outward direction.
I think that the best solution would be to not use physics on whatever's inside the ball. Put an animated character there, and play running animations, but instead of moving that character and having physics make the ball roll, just roll the ball by using rigidbody.AddForceAtPoint at some appropriate point along the sphere.. Not only will that fix your problem, it'll probably be a lot easier to tune than having things work with a character inside.
Edit: you should also experiment with AddTorque or AddRelativeTorque, depending on your need. Keep the model in the center of the ball in place by setting it as a child of the ball, and then setting it's local rotation to the correct value every frame.
Your answer
Follow this Question
Related Questions
Material Sphere Green 1 Answer
Increase the radius of Unity's primitive sphere? 1 Answer
How to set a boundary around an object? 1 Answer
Newbie starting out bit stuck :( 1 Answer
overlap half sphere? 0 Answers