- Home /
No bounce in 45° boxes ?
Hi erverybody,
I am trying to build something like CandyCrush but with 45° rotated boxes. It is my first project and as far as it goes it makes really fun.
I build 3 Boxes, set them to X=0 and rotated them in an 45° angle. Added Rigidbody and a BoxCollider2D. When they now drop they seem to partly fall inside of each other, then bounce to top, down again etc.. The problem seems to persist because of this Script : void Update () { Vector3 pos = transform.position; pos.x = 0; transform.position = pos; } The idea is to build x instances of my cubes later with an fixed X and let them fall into the scene at the right position.
Does anybody have an idea how to achieve this in an other way, or how to fix this bouncyness ?
The title is confusing -- sounds like you want to use rigidbody physics to make a grid-based game. I would almost say to make it purely grid-based first -- everything snaps. Then add rigidbodies later for decoration.
Take a look at locking an axis (in the rigidbody) and using is$$anonymous$$inematic to freeze them. Because 10 stacked rigidbodies act like gelatin squares.
I think you understand what I want. I didn't had any other idea how to make a grid based game. Gonna look for a tutorial of a grid game without physics.
Seems to me, the main part of a game grid is knowing how to use 2D arrays. Like using a loop to find the 1st used spot in a column, and another loop to find the next used spot.
That's standard computer program$$anonymous$$g stuff, but takes a while to learn if you don't already know it. Like, you start with stuff like finding the last 'x' in a 1D array.
Don't have a problem with using 2D arrays :). thing is I tried it without an array, just with phycs and exact measurement. Should be much easier with a standard boardobject and an array with BoxObjects.
Answer by sedativechunk · Jun 15, 2014 at 08:49 AM
I'm not sure exactly how or what you are trying to do. But what I can tell you is that if you DON'T want the boxes to interact with each other via physics then you can mark the "is trigger" button on the colliders. When objects are not triggers, they will use unity's physics engines, so if you are boxes are rubbing/sliding together like you say, there is a good chance that is what is making them "bounce". If you stacked them all using colliders and nothing is holding them in place, then you may have to find some other workaround for the problem.
I want them to interact, but more with something as a "stop" component. IF they collide thzey just shouldn't drop into each other, bounce away or anything else.
Answer by hayer · Jun 17, 2014 at 09:34 AM
See http://docs.unity3d.com/430/Documentation/Components/class-PhysicsMaterial2D.html
Try setting Bounciness(Restitution?) to 0.0.
Edit: [Adding some info] Since Unity is using Box2D(if I'm not mistaken) there will nearly always be a small overlap before the collision is resolved and approprierte forces are calculated and applied to the objects.
Your answer
Follow this Question
Related Questions
need help please! 0 Answers
I need an Einstein! Destroying part of a cube/mesh 0 Answers
How to move BoxCollider2D so it covers a line renderer? 0 Answers
Collision problem 0 Answers
2D Animation does not start 1 Answer