Hi all, so there’s a problem I can’t get my head around. I’m not asking for code, I just want advice and pointing in the right direction.
I’m making a local multiplayer game, which can play up to 4 players. I have 4 player game objects with player inputs components. All working as planned, no problems! Very pleased! The 4 objects have a sprite renderer each which is rendering a different colour sprite for each player ship. I would like though player 1 (user #0) to always be blue, player 2 (user #1) to always be orange etc…
I’m not near my PC, so bear with me, as I don’t have example code, or diagrams but will try and explain everything the best I can.
The problem I have come across though is every time the game is run, (application closed and restarted), players (users) are re-assigned to different game objects. Now on my main menu I have 4 sprites representing each object with text rendering above. I currently have the text P1, P2, P3, P4, rendering above each sprite to show which colour will be which player.
On the menu once I’ve grabbed the user number I will have an action which just highlights the corresponding colour when a gamepad button is pressed! So each player could press a button and find out what colour they are. User#0 will have a separate action map assigned which also has the menu control actions.
On the start of each level scene, all I need is too be able to grab the user number from the PlayerInput component, and I can then change the sprite of that object to match the diagram from the menu, that way every user will always be the same colour, regardless of how many times the application is restarted.
I have tried using the below properties to no avail. I’m sure InputUser stores the user number somewhere that’s easy to get, but I can’t seem to get it from anything I’ve tried in the docs.
InputUser user {get;}
PlayerInput user {get;}
Playerindex {get;}
I’m almost certain it’s going to be the InputUser user {get;} but I just couldn’t get it it to work with errors saying I can’t convert this to this, or when there was no errors, it was just showing 0, like it wasn’t receiving any data.
So to conclude, I just need to be able to grab the current user number from the player input component as say an int, so I can then check it and adjust players, actionmaps etc. Just a nudge towards the direction I need too be heading would be great.
Thank you all for any advice, reply in advance! I’ll buy you a beer if we meet in person!