Search Unity

Execution Question: WarioWare - Smooth Moves, Block Party

Discussion in 'Game Design' started by DevMerlin, Jan 16, 2021.

  1. DevMerlin

    DevMerlin

    Joined:
    Dec 21, 2011
    Posts:
    96
    I'm working on building a basic format essentially identical to Block Party at it's base:



    However.. at this point, I'm not having much luck. It feels like Unity's physics weren't built to handle things in a similar manner.

    At least half the problem is the moving platform. I've tried a number of recommendations, including this:



    That worked well.... for the first block that hit the platform. After that, subsequent blocks totally ignored the sensors on blocks that were already "locked".

    Joints don't work well, or don't seem to:

    Code (CSharp):
    1.         if ((impact == "Block" || impact == "Platform") && !joint) {
    2.             bRB.velocity = Vector3.zero;
    3.            
    4.             joint = gameObject.AddComponent<HingeJoint>();
    5.             ContactPoint contact = c.contacts[0];
    6.             joint.anchor = transform.InverseTransformPoint(contact.point);
    7.             joint.autoConfigureConnectedAnchor = true;
    8.             joint.breakForce = 150;
    9.             joint.connectedBody = c.rigidbody;
    10.         }
    That... also works for just the first block, then breaks if more are added - even slowly. Are there any suggestions for how I should handle this with Unity's physics system?
     
  2. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    551
    When I worked on character controller, I read (or in some cases, calculated) velocity vector of the platform, and simply added it to character rigidbody velocity (I think with Rigidbody.AddForce(ForceMode.VelocityChange)) while character was touching the platform. Worked consistently. Will be even easier for you since you do not need to handle edge cases like platform rotation or the brick being controlled by a player. All you need is to detect collisions reliably.
     
  3. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    551
    And I have the suspicion that you'll need to do it on per block basis. So each block will run tests for proximity of another rigidbody (perhaps with trigger collider slightly bigger than itself and OnTriggerStay) then - if it is actually standing on it (raycasts downward, maybe several), and finally apply the "platform" velocity to its Rigidbody if criteria are met
     
  4. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    What's actually going wrong? It's really difficult to diagnose a lack of luck and a feeling about a piece of software. ;)

    How are the results you are getting different from what you want?

    From the video you posted it looks like each block is a separate physical object, and that the idea is that players have to be careful when moving the platform to not disturb the blocks already on it. If that is the case then they need to stay as separate physical objects, which means you'll need to carefully tweak the bodies, forces, movement and friction values to get them to behave just as you want. That stuff is tricky to get right.