Ogreleg Posted March 30, 2021 Share Posted March 30, 2021 Is there any way to apply direction fix to the player? Ideally, I imagine a scenario where the player can hold down the Shift key (or whatever) and lock their direction for strafing or walking backwards. Link to comment Share on other sites More sharing options...
0 Ogreleg Posted February 18, 2023 Author Share Posted February 18, 2023 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 More sharing options...
0 Arufonsu Posted March 24, 2023 Share Posted March 24, 2023 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. Ogreleg and Artheios 2 Link to comment Share on other sites More sharing options...
Question
Ogreleg
Is there any way to apply direction fix to the player?
Ideally, I imagine a scenario where the player can hold down the Shift key (or whatever) and lock their direction for strafing or walking backwards.
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now