Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug 2D Collider Skewing off Image Axis

Discussion in '2D' started by supposedly_spooky, Jun 15, 2023.

  1. supposedly_spooky

    supposedly_spooky

    Joined:
    Feb 24, 2021
    Posts:
    1
    I'm having a really weird issue with my 2D collider on a moving image. When the player moves their head, the trigger moves away from the image it's attached to. Here's my code for making the image move.

    Code (CSharp):
    1. secondHandTransform.eulerAngles = new Vector3(secondHandTransform.eulerAngles.x, secondHandTransform.eulerAngles.y, -timePassed * 12f);
    The canvas's render mode is Screen Space - Camera which is important for some other stuff I have so I can't change that. I have tried putting the collider on a child object, but that doesn't work. I've tried removing the rigidbody, but that doesn't work either. Thoughts?

    HandInnacuracy.JPG
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,468
    Why are you trying to rotated something that exists in the 2D XY plane in 3D XYZ space? This just won't work. If you want that then use 3D physics.

    There really isn't enough information about to know what is actually going on though.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    If you find yourself reaching for transform.eulerAngles and reading data back from that, that's a "tell" for you to stop and rethink your strategy.

    Here's why:

    All about Euler angles and rotations, by StarManta:

    https://starmanta.gitbooks.io/unitytipsredux/content/second-question.html

    How to instantly see gimbal lock for yourself:

    https://forum.unity.com/threads/confusing-bug.1165789/#post-7471441