My controls change when I rotate my player in my 3D game

About Monkey 2 Forums Monkey 2 Programming Help My controls change when I rotate my player in my 3D game

This topic contains 3 replies, has 2 voices, and was last updated by  En929 3 weeks, 6 days ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #15958

    En929
    Participant

    In my 3D game, I am having problems with my rotation. When I first start the game, the player goes Forward (Z), Backwards (Z); it rotates to the Right(Y) and rotates the Left (Y) normally. However, when I rotate my player 90 degrees. After that, when I press the up button, the up button starts acting like the Right button, etc.  and all of the controls change and they change in every 90 degrees in which my player is rotated. Thus, what do I add to my code to get the controls to go in the way that the player is facing. My code is below. Thanks:

     

    #15992

    Ethernaut
    Participant

    Had to modify the code to run without the assets, but it seems that if you change the Move and Rotate commands to be in local space the problem is solved. Works here.

    Example:
    Man.MoveZ(0.2, False)
    Man.RotateY(1, False)
    (uses “false” instead of “true”)

    As far as I can tell, Mojo3D’s rotation and translation commands’ object space are inverted – True should mean local space, but means world space. If you want the motion to always be relative to where the player is pointing, it need to be in local space (“False”, although it should be “True”).

    #15993

    Ethernaut
    Participant
    #15995

    En929
    Participant

    Ethernaut, that worked. It fixed the problems! Thanks a lot!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.