Search Unity

Question How to make player rotate around an object?

Discussion in 'Scripting' started by margonvinther, May 26, 2023.

  1. margonvinther

    margonvinther

    Joined:
    May 12, 2019
    Posts:
    4
    I have a fps controller which I would like to rotate around an object when a button X is pressed. But the login to make it work I'm not quite sure about, I assume that I turn off the players rotation when X is pressed, and then maybe make the player a child of the object and then start rotating that?

    This is to try and throw the player, to rotate the object with the mouse and release X to send the player flying.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,695
    That will actually work really well... then just wait for the release and deparent it.

    You will almost certainly need to "back compute" the speed of the rotating player at that point in order to keep them flying along that direction.
     
  3. margonvinther

    margonvinther

    Joined:
    May 12, 2019
    Posts:
    4
    Thanks you the help. I will try to look into it, but I'm still not quite sure about the logic
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,695
    The only way to get sure about logic is to practice, practice, practice.

    Nobody can press that knowledge into your brain, certainly not by using this little text box.

    Build each step up one part at a time. Test, test, test, change it, understand what you're doing.

    Iterative development for the win.