Search Unity

Is this possible in Unity? High speed collision setup...

Discussion in 'Physics' started by Kaji-Atsushi, May 1, 2015.

  1. Kaji-Atsushi

    Kaji-Atsushi

    Joined:
    Oct 6, 2012
    Posts:
    234
    https://www.dropbox.com/s/q8dx35zwnchux0i/Grr.mov?dl=0

    Basically the scene is composed of a sphere which is connected to a spring which is connected to a cube.

    The hierarchy of each CubeBall is this: Parent Game Object > Cube(with spring component), Ball.

    I have a simple script on each sphere to have an impulse force downwards every couple of seconds.

    Each Parent Game object has a script to tell it to move to the right.

    The Parent game object on the top is using
    Code (JavaScript):
    1. transform.Translate(Vector2.right * Time.deltaTime, Space.World);
    The parent gameobject on the bottom is using
    Code (JavaScript):
    1. <Rigidbody2D>().MovePosition(transform.position + Vector2(1*Time.fixedDeltaTime, 0));
    All objects have the Rigidbody component.

    As you can see the result of moving the Parent using rigidbody position vs transform position results is very different. The rigidbody script transfers over the parents momentum/velocity making the sphere swing left and right.

    THE PROBLEM:
    I don't want the sphere to swing left and right. I want it to be like the one on top, but there's a problem with it, it cannot handle high-speed collisions. In order for me to have proper high-speed collisions, it appears I need to use rigidbody code and have the rigidbody components on the game object with the collision detection set to continuous.

    So how can I accomplish the movement of objects on the top of the video using rigidbody components and code in order to have proper high-speed collisions.