Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question no collision, object falls through

Discussion in 'Physics' started by spanduro, Mar 20, 2023.

  1. spanduro

    spanduro

    Joined:
    Mar 6, 2023
    Posts:
    4
    Hello
    I have a small problem, I have a bat and a ball, the bat is controlled by an external sensor (IMU), but if I move it too fast, the ball falls through. I detect the collision, but the ball falls through.

    The ball has a rigid body with Collision detection: Continuous.
    The bat has a rigid body with Collision detection: Continuous Dynamic.

    I move the bat in the bat's update method, with:
    this.transform.position = positionFromSensor;
    this.transform.rotation = rotationFromSensor;

    Can anyone point me in the right direction?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    A Rigidbody is in charge of the Transform. Its role is to simulate and write to the Transform. You're bypassing that and making it read the Transform to update its pose when the simulation runs. This might be in an overlap or completely beyond colliders.

    Physics isn't a rendering system, you need to use the Rigidbody API to cause movement and not the Transform.

    Also, you'll also need colliders on the bat/ball (you didn't mention them).
     
    spanduro likes this.
  3. spanduro

    spanduro

    Joined:
    Mar 6, 2023
    Posts:
    4
    Great, that helped quite a bit, thanks...

    Say hello to Tinky-Winky from me :)
     
    MelvMay likes this.
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    Qapla' !