Jump to content
  • 0

Fixed Direction on Player?


Ogreleg

Question

2 answers to this question

Recommended Posts

  • 0

Still looking for an answer on this one if anyone has time to throw me some info.

I found this function in the Player.cs file. Can this turn in place option be modified to instead lock player facing while the key is held down?

Β 

private void TurnAround()
        {
            // If players hold the 'TurnAround' Control Key and tap to any direction, they will turn on their own axis.
            for (var direction = 0; direction < Options.Instance.Sprites.Directions; direction++)
            {
                if (!Controls.KeyDown(Control.TurnAround) || direction != Globals.Me.MoveDir)
                {
                    continue;
                }

                // Turn around and hold the player in place if the requested direction is different from the current one.
                if (!Globals.Me.IsMoving && Dir != Globals.Me.MoveDir)
                {
                    Dir = (byte)Globals.Me.MoveDir;
                    PacketSender.SendDirection(Dir);
                    Globals.Me.MoveDir = -1;
                }

                // Hold the player in place if the requested direction is the same as the current one.
                if (!Globals.Me.IsMoving && Dir == Globals.Me.MoveDir)
                {
                    Globals.Me.MoveDir = -1;
                }
            }
        }


I'm still new to C# and multiplayer game development so I am not familiar with packet sending, though I am learning as I go. Can I just change this function or do I need to do something with packets in other class files?

Any tips would be appreciated.

Link to comment
Share on other sites

  • 0

Hey there, implementing direction lock while the player is moving can be a pretty challenging task right now, specially if you're new to C#, this is because the current implementation ties the player's facing direction to their movement direction.. A collaborator suggested that it might be easier to rework the movement system to be pixel-based (something that we really want to do eventually...), which would allow you to separate the facing direction from the movement direction with ease. However, if you're set on the current implementation, you can give it a shot ofc. Keep in mind that you may need to tweak other class files to ensure that the facing direction updates correctly and that packets are sent as expected.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...