The game I am trying to make include local multiplayer to play on same PC. I have done by making the different controllers in input manager and game work perfectly fine.
But now I am onto the part where I have to create a character selection screen for multiple player on same PC. I am beginner to the unity and learning right now. So I have no idea how to make it happen. Because when I tried to make it unity UI didn't able to take two input. At a time
I have also watched some of the threads in which people suggested to make your own eventsystem and button but I tried doing that somehow buttons are not taking any response they are not clickable. If anyone has seen those thread and that method is working for them, so please let me know how to.make it work
Or if someone has any other idea how to do please let me know
Thanks in advance
As far as I know, you CAN'T have more than one event system in the same scene.
So knowing that I'll suggest to change the...perspective about your game, here is something that can work:
You can't have more than one input on the same UI, but you can distinguish "keyboard" inputs. So let's guess the scenario that you have the screen divided in 2 parts, where left side is the Player 1 selection character, and can select between 2 characters, and right side is the Player 2 selection character, with the same number (or different, as you want!) of possible characters.
The pseudo code will be something like:
private Player m_player1;
private Player m_player2;
private CharacterSelection m_CharacterSelection_Player1;
private CharacterSelection m_CharacterSelection_Player2;
If (m_Player1.Input.GetKeyDown(KeyCode.A))
{
m_CharacterSelection_Player1.Left();
}
else if(m_Player1.Input.GetKeyDown(KeyCode.D)){
m_CharacterSelection_Player1.Right();
}
If (m_Player2.Input.GetKeyDown(KeyCode.LeftArrow))
{
m_CharacterSelection_Player2.Left();
}
else if(m_Player1.Input.GetKeyDown(KeyCode.RightArrow)){
m_CharacterSelection_Player2.Right();
}
Here is the visual representation about what I'm trying to tell you:
Related
So basically I have two questions. I am also copying off this video from 2014: https://www.youtube.com/watch?v=w8JgpEjm8i8&t=2792s
Question 1
At the end of the video above the guys computer completely crashed and he wasnt able to show the end of how to setup a death animation for my player (link). So currently I have setup a movie clip of the death animation - just the playing spinning around - and put it in another movie clip called 'All Sprites' in which I have my other movie clips such as the different walking directions. So I have placed it in there, labelled it with "Link Death Frame". I then went back to the main script and added code so that once my player dies, the animation will play. Such as:
~
if(linkHealthBarMC.scaleX <= 0.01)
{
linkAlive = false;
}
trace(linkAlive);
if(linkAlive == false)
{
linkMC.gotoAndStop("Link Death Frame");
}
~
However, the issue comes in which the animation doesnt actually play, it just goes straight to the first frame and doesnt play. I have tested it and I know for sure that it gets stuck on the first frame and that something must be wrong with the animation as I tested it with another animation and it worked fine (once I met the requirements for the animation to play). So does anyone have any idea how I can fix this issue so that my character can play a death animation?
Question 2
How do I stop time? Like just completely freeze everything after my character is dead? Because at the moment I am just going to the first frame of the death animation and can still move and attack.
I'd assume this is on an EnterFrame loop. Then you would have two possible causes for this:
1.) You're loop is constantly checking if the 'linkAlive' if statement is false (which it is) and setting your Animation to the first frame. You can check this method by putting a Trace statement in your if statement and if the output window overflows, then that's your culprit.
2.) What you want is gotoAndPlay(-insert label here-)
Tho it is outside the scope of the question you have, I create a variable~Switch State machine to control states for me:
1.) Current State as a number (int, number, or uint)
2.) function with a switch statement (Switch is kind of a fancy if Statement)
3.) inside the cases are instructions
switch(current_state){
case 1:
linkMC.gotoAndPlay('death animation');
break;
}
if (current_state != 1){
-put movement code here-
}
This is close to what I use for my game. Just checking states or you can have a variable like the one above that explicitly checks for the death state and remove the ability to move. If you use a mouse (and I assume event listener) then you can remove the event listener for the mouse. If you use a solution like keyboard inputs then an if statement would be more what you are looking for.
I'm using many AxWindows Media Players (AxWMPLib) to play sound in my piano application on Visual Studio. I'm not using them for video, and so they are all invisible. I also want to play my application in full screen mode. The full screen mode works fine with no media players, all the anchors work correctly as I want. This is the full screen without the Media Players and it is all good
However, as soon as I add one media player, it then looks like this? The anchors break and the full screen mode completely alters? I don't know why this happens, and I am really stuck as to why adding an AxWMPLib breaks the anchors like this, without altering the AxWMPLib at all.
Does anyone know why this is the case and how to fix it?
Thank you in advance :D
I have found an answer to this problem! I hope my solution below will help anyone in the future. If you are using AxWMPLib and want the form to be fullscreen, all the elements might not anchor correctly, and stay in the top left corner of the screen (like the screenshots in the question).
I found this to be caused by the WindowState Property in the Layouts section. Rather than setting the WindowState Property as Maximised, keep it as Normal, and then change the WindowState Property programmaticly in the Form_Load Sub, with the following code:
Me.WindowState = FormWindowState.Maximised
And then hopefully when you run the form, the form will still be fullscreen but the AxWMPLib won't cause it to go wrong, and everything should be anchored correctly.
all. I'm new to Matlab and I'm a bit stuck. The last piece of the puzzle to run my experiment is to get some human input (expert supervised system). As easy as this may sound, I just can't seem to figure this one out.
I need to display four images to the user, plus an additional fifth figure (button, or could even be another image, doesn't matter). The code should wait until the user clicks any one of those images/figures and should continue afterwards (closing the figures, too). Obviously, I'd need to know which figure was clicked.
GUI programming in Matlab doesn't seem to be documented clearly to me. Or perhaps it's just in a realm that I'm not talented with. It's definitely a lot more confusing than Visual Studio, that's for sure.
Thanks in advance for your time; I greatly appreciate it! :)
Could you make all five of the images into buttons? The 'CData' property of a button can be used to display an image on a MATLAB button. See the following links for an example and an explanation (that hopefully makes sense!).
http://www.mathworks.com/matlabcentral/fileexchange/2378-buttons/content/buttons.m
http://www.mathworks.com/support/solutions/en/data/1-16V03/
Use menu:
figure(1)
plot...
figure(2)
plot...
figure(3)
plot...
figure(4)
plot...
% this will create a menu of labeled buttons where the user can click
m = menu('Choose a figure','Figure 1','Figure 2','Figure 3','Figure 4','None');
% close all 4 figures
close(1:4) %will close figures 1 to 4
% --------- your program from here on ---------
if m == 5
display('You chose no Figure');
else
display(['You chose Figure:' num2str(m)]);
end
%---------
menu will return a number which corresponds to the option that the user clicked on.
Right, hi guys, I recently followed a tutorial http://xnadevelopment.com/tutorials/thestateofthings/thestateofthings.shtml where I wanted to create a sort of splash screen, and it worked I managed to get a two different screens interchanging between one another (so, if I press A, it goes to TitleScreen, and if I press B, it returns back to ControllerDetectScreen)
Here's the code http://paste.org/43859
Obviously there is no actual game, but if you could show me how to get rid of the TitleScreen and ControllerDetectScreen by adding a function to remove them both out of the way (preferably the spacebar, and to start my game (The background will be 'CornFlowerBlue after the function is added and pressed.)
Thank you!
Using the same code, you could add another bool for whether you're in the game or not, and another if statement wherever you need it to contain the code for the game (probably Update and Draw)
I wrote a simple program with SFML and OpenGL which draws a spinning square that can be moved around the screen with the arrow keys.
It works fine on all the Linux and Mac computers I've tested it on, but when I try to move the square on Windows (by holding down an arrow key) it moves a small distance and then stops moving and spinning. I'm pretty sure the program is getting stuck in the GetEvent method - my guess is that when I've held the key down long enough for it to start repeating, the event stack keeps getting new events added to it before I can pop everything off it (and if I turn the key repeat rate on Windows right down to the minimum then the problem goes away - I don't really like this as a solution though).
I found that pressing and holding Alt, Ctrl, Delete, Page up, Page down, Home, End etc all cause this behavior too (even though I don't specifically detect any of these keys in the program), but all the letter keys, as well as space, enter, backspace and the keypad arrow keys work fine (i.e. they don't cause the program to pause if I hold them down for too long).
I don't have the exact code (I just turned my laptop off), but it looks like:
while(running) {
while(app.GetEvent(event))
if(event.Type==sf::Event::Closed) running=false;
if(input.IsKeyDown(sf::Key::Right)); // move right
// etc etc
// update rotation
// draw everything
}
Any ideas as to what the exact problem might be, and how I could fix it?
I know this is an old question but I would like to answer it in the interest of helping others who may find themselves here experiencing similiar problems.
SFML 1.6 has two ways you can get input from the user. One is event-based where you process each event sent to you via sf::Window::GetEvent(). The other is query-based where you check the sf::Input class of your window directly.
You have used the query-based method here but put it inside an event loop which isn't really the way it was intended to be used. It was meant to be used like this. This is a nice feature because SFML essentially keeps a boolean table of keys automatically for you so you don't need to manage key states yourself. IMHO for using repeating input this is more elegant since you won't be spamming your event queue, just checking a boolean value.
while(app.GetEvent(event))
if(event.Type == sf::Event::Closed) running=false;
if(event.Type == sf::Event::KeyPressed && event.Key.Code == sf::Key::Right)
{
// move right
}
}
If you wanted to just query sf::Input directly then you use the same code as above, but you put it outside the event loop.
while(app.GetEvent(event)
{
}
if (myWindow.GetInput().IsKeyDown(sf::Key::Right))
{
}
By default automatic key repeat should be enabled for sf::Windows but you can make sure by using sf::Window::EnableKeyRepeat(true). This means it will send a KeyPressed event repeatedly while a key is held down.
Try using the query-based method outside the main event loop and see if that works for you.