On a collision trigger my game object auto transforms to cords 0, 0, 0

Hi,

I have what seems to be odd behaviour in my version of Unity. The version is 2020.3.25f1. I noticed the behaviour when I get this far in the course, but I have been able to strip back everything to the basics in order to reproduce.

The issue is that when there is an edge collider 2d and the surface effector 2d on the sprite shape, any other collider with the isTrigger set to true will “teleport” from it’s position in the game world to the cords 0,0,0. It is really easy to reproduce this just by doing the following:

  1. Create a new 2D unity project
  2. Add a default closed sprite shape
  3. Add a edge collider 2d to the sprite shape
  4. Add a surface effector 2d to the sprite shape
  5. Add a dynamic sprite over the sprite shape
  6. On the dynamic sprite’s collider set is trigger to true
  7. Click play and observe that the dynamic sprite will teleport as soon as it hits the sprite shape

I have captured the behaviour in a youtube video that you can see here - https://youtu.be/rpVRemIRNvg

Do you have any idea what could be causing this behaviour?

Hi,

Thanks a lot for the video. That was really helpful. :slight_smile:

I assume that the SurfaceEffector2D adds speed to the “Dynamic Sprite” game object. For testing purposes, you could set the speed to 0 or a very low value to see what happens.

Set the “Interpolate” value of the Rigidbody2D component to “Interpolate”.

Also move the “Dynamic Sprite” game object higher. The game window is a laggy preview. When you start the game, there is usually a brief moment where it noticeably lags. By moving the game object higher, you give Unity time to load stuff, and maybe the game object won’t teleport anymore but move.

Hi Nina,

Thanks for all of the tips. Unfortunately, none of these resolved the issue, but I did figure out that it was a bug in the version of Unity that I was using:

Once I updated to a 2021 version the issue was resolved.

That’s interesting. I didn’t know about this bug. Thanks for sharing the link! :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms