- Home /
What approach would you recommend for a coindozer game
What would be the best approach to create a coindozer game?
I started with boxcolliders and rigidbodies but because i have around 200 objects with this components in a single scene on a mobile device the frame rate drops to the minimum which is 3 fps.
After that i tried grouping the coins in rows of 8 and columns of 10 and 2 or three coins stacked on top of each other for each column and row pair. But the problem here is that those formation don't look random at all and it does need to be random as well.
What approach would you choose if you would make such a game, if you have some example code or link or forum i would really appreciate it. Thanks a lot and have fun with Unity.
makes me realize RT game physics has a way to go !
BTW this is an example of an amazingly out of date Q/A on this site :) (2014)
Answer by Fattie · Sep 19, 2012 at 09:25 AM
Man, this would be hard to do well.
You may have to control them completely manually (kinematically) until they get to the edge
Only as they tumble over, kick in the physics and let PhysX do a fantastic random tumble for you.
how's that ?
BTW are you using an ortho camera? Why?
That is actually an image made from the scene view while the game was playing in the editor. I am working on unity3d set to android platform and i don't know why when i test it in the editor with a perspective camera the objects seem to enter one another and it looks really bad(when it's set to PC platform it looks good).
Well thank you for the answer.
BTW would it make any difference regarding your idea if the coins would be positioned randomly in 2 groups one on the upper platform and one on the lower platform?
Even though you ticked this answer I hope others can bring better suggestions to this !!
In answer to your third question, yes I would position them randomly and then write routines to "manually" do the physics as the dozer pushes them around.
I have to believe there's a better way hopefully someone else has it!
personally I'd just do it all physically and tell people to buy faster hardware :)
Yeah that is hard to do well - so many things to simulate.
I guess my first thought would be to divide the coins into layers on each shelf - then solving coin movements becomes a circle -> circle overlap detection which is pretty fast. If a coin ended up unsupported after movement then you'd turn on the Physics per @fattie's answer. You'd turn off physics when the coins up vector was world up and go back to simulation. All of the non-physic coins would probably have to be attached to a kinematic rigidbody anyway to support interaction with the physical ones. Guess you'd also have to turn impacted coins into physics objects when something fell on them. Hmmmmm. Not easy at all.
I understand what you mean but i'm not sure how to make a circle overlap detection. That part about the coins vector up to be world up vector will help me out because right now i am using 2 box colliders with rigidbody for each one and the coins are children to those objects.
I have 2 plane triggers placed where the coins should fall and the moment one of objects enters such a trigger it checks for that object if some children have reached or passed the trigger plane and if that is true i add to those coins box collider and rigidbody and set their physics so that it ignores the ex-parents collider and after that i resize the parents collider so that it fits all coins that are children of its.
$$anonymous$$y problem that was solved by your idea is that when i insert new coins i didn't knew when to make those coins children on the object they are colliding with, but now i just check for its up vector and then i make it a child.
Thank you very much.
So let me preface this with - this is difficult and may not work!
I was thinking that you could basically choose a layer for the coins and then when the dozer pushes them you would process each layer at a time. Circular collision detection is easy as two points that are within the coin diameter of each other would be colliding and the normal of that collision is a 90 degrees rotation of the line between them going through the intersection point on the radius of either coin. So it is practical to imagine you could simulate the physics yourself under such circumstances in a more optimal way than PhysX would - you've constrained the model. You would let PhysX handle any coins that were not flat.
You still have to get these aligned coins to interact with other physical coins though - these would be any where there was no support from the shelf or enough coins below the pushed coin. You would probably get away with only working that out after perfor$$anonymous$$g all of the simulations for the layers - it would probably look realistic because it would be fast.
Your answer
![](https://koobas.hobune.stream/wayback/20220613081133im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Raycaste vs trigger Colliders & Rigidbody performance 1 Answer
Is it slow to move a rigidbody's child/compound collider? 1 Answer
Performance hiccup on initial contact with rigid bodies 0 Answers
Add 2d rigidbodies to moving objects to increase performance or not? 1 Answer
Detecting Input on ~100 Objects 2 Answers