Search Unity

Manipulating physics simulation

Discussion in 'Physics' started by diegzumillo, May 6, 2019.

  1. diegzumillo

    diegzumillo

    Joined:
    Jul 26, 2010
    Posts:
    418
    Hey

    I have a very specific problem to solve in my project. Physics objects (rigidbody2D) need to exist in two locations at the same time. They move in synchrony, but their local space might be rotated relative to one another. If one hits the ground and bounces up, the other bounces up too. I can almost solve this with some clever use of joints and colliders but when one is rotated with respect to the other (so down for one is left for the other, for example) then I don't think there's a simple way around.

    Is there a way I can take collision data from one object and send it to the other. I tried the naive way here, of calling oncollisionenter manually on the other when one is called, but that doesn't trigger the collision (the other way around, obviously). So if there's some way I can intercept the physics simulation and make an object hit a wall that isn't there, that would be great!

    I'm asking because if that doesn't work then I'll have to do my own physics simulation and, man, I hate doing that. I did it once and it was so messy I can't use that code again. Not to mention it won't have a nice performance as the native solution's.