hello.
I just completed a 2D roguelike tutorial. Right now, I'm making a roguelike in 3D.

How can I make the player face the direction of movement in 3D?
For example, when I press the 'D' key, I want the player to always look right in world coordinates.
Conversely, when pressing the 'A' key, I want the player to always look left.

I've been thinking and trying for hours, but I don't know how to do it properly, so I would appreciate it if you could give me a hint.

(I have ORK)
Post edited by sss on
  • Are you using this movement schematic from the roguelike tutorial?

    image

    You might run into an issue I had when transitioning to 3D from the 2D Grid Battle Tutorial:
    gamingislove said: For turning into movement direction with this setup, change the Change Position node's rotation setup:
    - rotate component: Transform, otherwise it'll try rotating with the attached rigidbody, which is set to be kinematic (i.e. not doing anything)
    - lock rotation: enable X and Z (i.e. it'll only rotate on the Y axis)
    Your Game Settings Default Horizontal Plane should be set to XZ. Look over the settings in the Change Position node; try the Face Direction option there. Or you can try using Rotate To nodes before Change Position.

    Just throwing out some ideas for you. Maybe someone else has a better answer.
  • This depends on how you move the player. Most movement nodes have an option to face the movement direction (mainly for 3D), but as @Scyra said, you might need to change the rotate component setup of the node (also depending on your player's setup, e.g. how it's moved, etc.).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • ssssss
    edited August 2
    Thank you for your reply , Scyra and gamingislove.
    It was helpful.

    Yes, I'm using roughly the same as that schematic.
    I am using a Ray cast node and a Change position node.
    Players now face in the direction they are going.
    But I still can't solve the problem.

    For example, each time I press the D key, the player will additionally turn to the right.
    In other words, if I press the D key 4 times, the player will go around and return to the starting position.

    Regardless of the current player's direction, when I press the D key 4 times, I want the player to move 4 squares to the right from Initial position.

    Raycast is the same.
    I want to look one square to the right of the player, regardless of the player's current direction.

    Is there a way to do so? 
    Post edited by sss on
  • ssssss
    edited August 3
    I found one solution. I'll make a note of it for myself.
    Suppose you want to press the D key to go right.

    Prepare a object variable (eg "DirectionPlayer").
    Prepare 4 Check Transform nodes to determine if the player's Rotate is 0, 90, -180, or -90.

    In each case, set the value of DirectionPlayer to (1,0,0), (0,0,1), (-1,0,0), (0,0,-1) .

    And in the Change Position node, use this DirectionPlayer.

    I succeeded in doing what I wanted to do.
    (The downside is that this method requires a lot of nodes.)

    postscript
    Again, it may not work.
    Post edited by sss on
  • Maybe you can trade the 4 Check Transform nodes for one Orientation Fork?
  • Maybe post a screenshot of your schematic and some of the node settings (e.g. movement/rotation nodes) - that'd help figuring out what's going on :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thank you for your reply , Scyra and gamingislove.

    >Scyra
    I looked into Orientation Fork.
    It's like a node that checks where another object is relative to the player.
    Maybe it's just my lack of knowledge, but I couldn't think of a way to replace it. sorry.

    >gamingislove

    Schematic
    image

    pattern 1
    I tried pressing the D key four times.
    If Face Direction is disabled.
    The character moves correctly, but the direction of the character is not changing.
    image

    image


    pattern 2
    I tried pressing the D key four times.
    If Face Direction is enabled.
    Characters do not move correctly.
    But the direction of the character changes correctly.
    image

    image


    I would appreciate it if there is a better way.
  • Disable Local Space - this uses the direction in local space of the moving combatant, so facing direction also changes the direction. Having it disabled uses it as a global direction.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • ssssss
    edited August 4
    Thank you. solved.

    I actually tried disabling localspace once before asking the question. However, since the movement was strange, I misunderstood that this would be a mistake.

    There was actually something to do in addition to disabling localspace.
    In the two ChangeVariable nodes, change the Operator item to "Add" instead of "Set".
    Now everything works properly.

    I apologize for wasting your time on such a simple matter.
    Thank you very much.
    gamingislove and Scyra.
    Post edited by sss on
  • Hey, good job. About Orientation Fork: I use it From: Machine Object, To: Selected Data: cell, to see where the next grid cell is relative to the player and play appropriate turning animations. Anyway, it sounds like you're all set now. Good luck.
Sign In or Register to comment.