Search Unity

Perpendicular to circle surface help

Discussion in '2D' started by ahmetttmarket1971_unity, Feb 12, 2020.

  1. ahmetttmarket1971_unity

    ahmetttmarket1971_unity

    Joined:
    Feb 12, 2020
    Posts:
    3
    Hi guys
    We are developing a game that you need to jump from circle surfaces to another circle surface areas. Our problem appears here that when we jump to another planet our character loses its perpendicular angle with the tangent line to the circle surface. When this happens, it starts to lose its path and jumps to another places which are not other circles and targets. So what can be done to this? Its 2D game
    For more information we could upload some images to make you understand. Need help.
     
  2. ahmetttmarket1971_unity

    ahmetttmarket1971_unity

    Joined:
    Feb 12, 2020
    Posts:
    3
    Here is the what I have tried to say;
     

    Attached Files:

  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    2,526
    There's no way to help you without clearly describing what is actually going wrong and what you expect to happen. The above statement is quite confusing and a little vague.

    You should explain this part in particular better. Your attached image shows a circle, a normal and a tangent which are all familiar concepts but doesn't provide more info.

    A video show it going wrong and what you expect to happen might help or just a more detailed description.
     
  4. ahmetttmarket1971_unity

    ahmetttmarket1971_unity

    Joined:
    Feb 12, 2020
    Posts:
    3
    an object when it hits to a circle, we want that object to make it perpendicular to circle's surface. When object hits to the circle, its rotation change. We dont want that happen. We just want to ensure that wherever the object comes from, when it hits, it should be perpendicular.
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    2,526
    Right, so how have you got this set-up right now? Obviously a Rigidbody2D set to be dynamic will just hit the circle and it won't know to be aligned with the surface as that isn't a physical behaviour for a rigidbody.

    If you use a dynamic body then it'll react to hitting things which will cause it to rotate and move away from the surface which you don't want. If you constrain it so that it cannot rotate using rigidbody Z rotation constraint then you won't be able to rotate it unless you simple set the rotation directly which isn't recommended for a dynamic body.

    The best thing is to handle the movement yourself. Have a Rigidbody2D set to be Kinematic. Use queries to determine what it hits and if you know you're landing on a surface then you can change the movement so that you rotate around the surcace (always pointing towards its center) and any left/right movement simply move around the surface (tangent). Jump would also be along the surface normal.

    I have a repo I maintain here: https://github.com/MelvMay-Unity/UnityPhysics2D. Whilst I've not got an example of such movement (which I might go ahead and do because it's a cool idea) I do have an example of kinematic movement here: https://github.com/MelvMay-Unity/Un.../Assets/Scenes/Miscellaneous/IsGrounded.unity
     
unityunity