EtG Modding Guide
  • ETG Modding Guide
  • Getting started
    • Modding EtG: Installing Mods
    • Modding EtG: Creating a Mod
    • Uploading a Mod
    • Useful Tools
      • Using IlSpy
  • Making An Item
    • Creating A Passive
    • Creating An Active
    • Creating An Ammolet
    • Creating A Guon
    • Synergies
  • Making a Gun
    • Creating A Gun
      • Setting Up Gun Sprite Folders
      • Creating Gun Jsons/Jtk2ds
        • Pixel Measurement Conversions
    • Setting Up Projectiles
      • Adding Components To A Projectile
      • Projectile HitEffects (Visual Effects)
      • Adding status effects to a projectile
    • Continuous Fire Animations
    • Gun Ammo Types
  • Custom Characters
    • Creating A Standalone Custom Character
  • Making a Floor
    • Introduction
    • Setup
    • Making The Dungeon
    • Tileset
    • Rooms
    • Making the flow
    • Making the Entrance
    • All Files
  • Text, Text Boxes, Etc
    • Textboxes
    • Text Formatting
  • Sounds
    • Using Custom Sounds
    • Customising Gun Sounds
    • Basegame Sound List
    • wwise Sound Dump
  • Misc
    • Making Asset bundles
    • Assetbundles: How-To
    • How to create a hook
    • Creating A Command
    • Subscribing Methods to Actions
    • Reversing Player Controls
    • Undodgeable Projectiles
    • Creating An Enemy
  • Shaders
    • Creating Shaders
  • All things Spriting
    • Important Sprite Creation Information.
    • Importing a Sprite To Visual Studios
  • Monobehaviour Documentation
    • BounceProjModifier
    • PierceProjModifier
    • KeyProjModifier
    • CompanionFollowPlayerBehaviour
  • Various Lists of IDs, Sounds, Etc.
    • List of Item and Gun IDs
    • Enemy Guids
    • List of Base Game Synergies
    • dfSpriteList
    • All Custom Ammo Types
    • Gun .Json Dump
  • OFF TOPIC MEMES
    • Modders Anthem
Powered by GitBook
On this page

Was this helpful?

  1. Misc

Reversing Player Controls

PreviousSubscribing Methods to ActionsNextUndodgeable Projectiles

Last updated 10 months ago

Was this helpful?

Difficulty: 1/10

To reverse controls drop this code block into whatever class you will have reversing the controls.

make sure you are using InControl; at the top

        private BindingSource[] ActionDownValueP1 = new BindingSource[4];
        private BindingSource[] ActionUpValueP1 = new BindingSource[4];
        private BindingSource[] ActionRightValueP1 = new BindingSource[4];
        private BindingSource[] ActionLeftValueP1 = new BindingSource[4];
        
        private bool HasAlreadyReversedControls = false;
        
        public void ReverseControlsP1(float AmountOfTimeControlsReversed)
        {
            
            GungeonActions actions = BraveInput.PrimaryPlayerInstance.ActiveActions;
            var ActionLeft = actions.Left.Bindings;
            for(int i = 0; i < ActionLeft.Count; i++)
                ActionLeftValueP1[i] = ActionLeft[i];
            var ActionRight = actions.Right.Bindings;
            for (int i = 0; i < ActionRight.Count; i++)
                ActionRightValueP1[i] = ActionRight[i];
            var ActionUp = actions.Up.Bindings;
            for (int i = 0; i < ActionUp.Count; i++)
                ActionUpValueP1[i] = ActionUp[i];
            var ActionDown = actions.Down.Bindings;
            for (int i = 0; i < ActionDown.Count; i++)
                ActionDownValueP1[i] = ActionDown[i];

            actions.Left.ClearBindings();
            actions.Up.ClearBindings();
            actions.Down.ClearBindings();
            actions.Right.ClearBindings();

            for (int i = 0; i < ActionRightValueP1.Length; i++)
                actions.Left.AddBinding(ActionRightValueP1[i]);
            for (int i = 0; i < ActionLeftValueP1.Length; i++)
                actions.Right.AddBinding(ActionLeftValueP1[i]);
            for (int i = 0; i < ActionUpValueP1.Length; i++)
                actions.Down.AddBinding(ActionUpValueP1[i]);
            for (int i = 0; i < ActionDownValueP1.Length; i++)
                actions.Up.AddBinding(ActionDownValueP1[i]);

            HasAlreadyReversedControls = true;
            GameManager.Instance.StartCoroutine(FixControlsP1(AmountOfTimeControlsReversed));
        }

      private IEnumerator FixControlsP1(float SecondsToWait)
        {
            yield return new WaitForSeconds(SecondsToWait);
            GungeonActions actions = BraveInput.PrimaryPlayerInstance.ActiveActions;
            actions.Left.ClearBindings();
            actions.Up.ClearBindings();
            actions.Down.ClearBindings();
            actions.Right.ClearBindings();

            for (int i = 0; i < ActionLeftValueP1.Length; i++)
                actions.Left.AddBinding(ActionLeftValueP1[i]);
            for (int i = 0; i < ActionRightValueP1.Length; i++)
                actions.Right.AddBinding(ActionRightValueP1[i]);
            for (int i = 0; i < ActionDownValueP1.Length; i++)
                actions.Down.AddBinding(ActionDownValueP1[i]);
            for (int i = 0; i < ActionUpValueP1.Length; i++)
                actions.Up.AddBinding(ActionUpValueP1[i]);

            HasAlreadyReversedControls = false;
        }

This grabs the current movement bindings and stores them in fields. It then takes what was up, and uses it for down, takes what was down and uses it for up, etc. Now I hear you cry, "But An3s, can't we just use negative movement speed to reverse controls?" No, you're stupid, and I hate you. Setting the value to a negative can lead to all sorts of jank and bugs: 1) touching a wall sticks you to that wall and you cant walk off it. 2) trying to enter a boss room soft locks the game. 3) the running dust particles are a never-ending stream. So it is just better to subtly switch the player binds.

Now things will break terribly if you try to reverse controls while they are already reversed, which is why we have the bool HasReversedControls in there. so whenever you call ReverseControls you make sure HasReversedControlls is equal to false. This code can work with player two with some tweaking, but I leave that up to you if you want it. to call it simply go:

if(HasAlreadyReversedControls == false)
    ReverseControlsP1(4);

where 4 is replaced with however many seconds you want controls to be reversed.