Istimis Posted March 26 Share #1 Posted March 26 здравствуйте, помогите пожалуйста понять в моём коде персонаж постоянно бежит, как написать правильно код, чтобы анимация бега работала, только когда клавиша нажата. modded class MissionGameplay { override void OnKeyPress( int key ) { Run( key ); super.OnKeyPress( key ); } bool RunState; void Run( int key ) { if ( key == KeyCode.KC_LSHIFT ) { RunState = true; } else if ( key == KeyCode.KC_W || key == KeyCode.KC_S || key == KeyCode.KC_A || key == KeyCode.KC_D) { RunState = false; } PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer()); if ( RunState ) { player.GetInputController().OverrideMovementSpeed( true, 3 ); player.GetInputController().OverrideMovementAngle( true, 1 ); } else { player.GetInputController().OverrideMovementSpeed( false, 0 ); player.GetInputController().OverrideMovementAngle( false, 0 ); } } } Please Log in or Register to see this: Attachment Link to comment Share on other sites More sharing options...
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