Home Game Development unity – Making 2 Player UI

unity – Making 2 Player UI

0
unity – Making 2 Player UI

[ad_1]

For follow, I’m attempting to remake the character choose display screen from Street Fighter II.

Screenshot of recreated character select screen

I managed get it working with a Grid Layout Group, ScriptreadyObjects, and a few scripts to have the 1P cursor transfer round and alter the portrait and textual content on the left.

What I do not know is the right way to make it 2 Player. The white space on the precise is the place I’m intending to point out the choice for the second participant, nevertheless I can not get 2 gamers to work right here.

Currently, the Player choice works utilizing WASD or the Arrow Keys (and the mouse, although I’d like some approach to flip that off for now because it causes bizarre issues to occur).

I’d like P1 to work with WASD and P2 to work with the arrow keys.

I’ve tried to make 4 new axes for the X & Y of every participant with totally different buttons and apply them to totally different Standalone Input Module parts, however that does not work (one typically finally ends up disabling the opposite).

I’ve additionally appeared into Event Systems, however wasn’t certain if this was relevant. I do not know a lot past the fundamentals of UI programming and I’ve by no means actually handled Event Systems and Event Triggers earlier than this. Nothing I do appears to let a second participant exist on this choice scene.

This is the script that I’m presently utilizing for choice. It makes use of parameters from a Character ScriptreadyObject I made to manage the graphics. However, my navigation inputs within the UI appear to be pushed by the Standalone Input Module.

utilizing System.Collections;
utilizing System.Collections.Generic;
utilizing UnityEngine;
utilizing UnityEngine.UI;
utilizing UnityEngine.Events;
utilizing UnityEngine.EventSystems;

public class ChoiceScript : Selectable
{

    //Our variables
    Image characterPortrait;
    Image characterNameSprite;
    Text characterName;
    CharDisplay character;
    public RecreationObject P1cursor;

    BaseEventInformation m_BaseEvent;//This is a approach for us to trace sure occasions in a Selectable object within the Event System.


    // Start is known as earlier than the primary body replace
    void Start()
    {
        character = GetComponent<CharDisplay>(); //We're going to make use of this to entry something we wish within the CharDisplay

        characterName = character.titleText; //The UI object within the CharDisplay Script we stated we needed to signify the title textual content
        characterNameSprite = character.charName; // The UI Object we wish to present the Name Sprite
        characterPortrait = character.portrait; //The UI object we wish to present the Portrait Art

        P1cursor = RecreationObject.FindGameObjectWithTag("P1Cursor"); // Automatically finds the P1cursor based mostly on tag
    }

    // Update is known as as soon as per body
    void Update()
    {

        if ((IsHighlighted(m_BaseEvent) == true)){ //If an object is highlighted...
            P1cursor.remodel.place = recreationObject.remodel.place; //Move the cursor to it.
            characterPortrait.sprite = character.character.Portrait; //Make the sprite of the Portrait UI Image we're accessing turn out to be the CharDisplay Character's outlined Portrait sprite.
            characterNameSprite.sprite = character.character.CharName; //Make the sprite of the Name Sprite UI Image we're accessing turn out to be the CharDisplay Character's outlined Name sprite.
            characterName.textual content = character.character.title; //Make the title within the further textbox we made equal the CharDisplay Character's outlined title textual content.
        }

        //This let's us know what we're deciding on.
        if ((IsHighlighted(m_BaseEvent)== true) && Input.GetKey(KeyCode.Space))
        {
            Debug.Log("You have chosen " + characterName.textual content.ToString());//We have to translate the title of the character right into a string for the console.
        }
    }
}

Anyone have any recommendation on making a 2-Player UI? I’m glad I used to be in a position to determine the 1P out, however I’d actually admire with the ability to discover ways to make a multiplayer UI.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here