Help with Character selection

B

bondfish

Guest
So I am making a character select screen with a box that highlights the selection. the problem that I am having is the spawner I created isn't spawning the character in the next room.

Code:
//create
global.Characterone = false;

//step

If(global.Characterone = true)
instance_create(x,yobj_characterone);
the pointer when you hit enter on the selection makes global.characterone =true; and goes to the next room. any ideas?
 

rIKmAN

Member
So I am making a character select screen with a box that highlights the selection. the problem that I am having is the spawner I created isn't spawning the character in the next room.

Code:
//create
global.Characterone = false;

//step

If(global.Characterone = true)
instance_create(x,yobj_characterone);
the pointer when you hit enter on the selection makes global.characterone =true; and goes to the next room. any ideas?
You are creating the instance in your select screen room, and then moving to the next room where it doesn't exist.

Depending on how your game works, either make the player persistent, or use room_instance_add()
 
D

Docker

Guest
You are creating the instance in your select screen room, and then moving to the next room where it doesn't exist.

Depending on how your game works, either make the player persistent, or use room_instance_add()
Not to mention it'll keep creating the object if you have it in the step event unless you do something to change that... and the , missing from between y and obj_characterone, and the capitalised I in if....
 

Posh Indie

That Guy
Also, in your code:

Code:
If(global.Characterone = true)
Is not actually doing what you almost certainly think it is. That is setting "global.Characterone" to "true", and then evaluating "true" every time. In other words, it will always pass (Making the "if" statement pointless, even if intentional).

So,

Code:
if(global.Characterone == true)
is probably what you are after.
 

andulvar

Member
Also, in your code:

Code:
If(global.Characterone = true)
Is not actually doing what you almost certainly think it is. That is setting "global.Characterone" to "true", and then evaluating "true" every time. In other words, it will always pass (Making the "if" statement pointless, even if intentional).

So,

Code:
if(global.Characterone == true)
is probably what you are after.
I don't believe that is true. Gamemaker doesn't differentiate = and == in an if statement.

Also for the op, unless you want to spawn a character every step there is no need to have the character spawning code in the step event. Ideally you would have that code in the creation block. Unless there is going to be a time when Characterone is false after the character creation room? If that is the case you'll need another variable to check if the player has already been spawned before spawning the character (again if you only want one character created).
 

Posh Indie

That Guy
I don't believe that is true. Gamemaker doesn't differentiate = and == in an if statement.

Also for the op, unless you want to spawn a character every step there is no need to have the character spawning code in the step event. Ideally you would have that code in the creation block. Unless there is going to be a time when Characterone is false after the character creation room? If that is the case you'll need another variable to check if the player has already been spawned before spawning the character (again if you only want one character created).
Apparently you are correct. I would highly recommend against it (And so does the documentation), regardless.

@bondfish I would also change your naming convention to something more legible (currently looks like some kind of inverse camelcase).

Of course, you are free to ignore me. It is just advice at this point, haha.

Oh,

Code:
instance_create(x,yobj_characterone);
I will add to previous corrections. "obj_characterone" should probably be "obj_Characterone" (or the other way around). That is unless they also do not enforce case-sensitivity... if so, I will start questioning the educational use of this software (Call me sadistic, but I already want to watch someone program in other languages thinking they can always use = in place of ==).
 
Last edited:

Fabseven

Member
Are global variable passed from your room to next room ?
If yes you could simply set a global variable in the first room and use it later.

room selection : global.cara_selected = obj_spiderman
room play : instance_create(10,10,global.cara_selected)


also, some people say you can use = in a if statement but i think you cannot.
use == so there is no risk at all.
 

Posh Indie

That Guy
...also, some people say you can use = in a if statement but i think you cannot.
use == so there is no risk at all.
Unfortunately, you can. See exhibit A:
https://docs.yoyogames.com/source/dadiospice/002_reference/001_gml language overview/401_04_expressions.html

I had been countered with "It is also a learning tool" on a few occasions, so allowing this in a learning tool is terrible, legacy support or not. It's one thing to keep throwing, "It is also a learning tool" in people's faces every chance you get, but another to allow counter-productive practices after doing so. That's just my two cents, though. Probably means nothing to who it matters to most in the grand scheme of things.

To whoever wishes to do it the legacy (Not recommended, but apparently allowed) way; "You do you, but blame only yourself when things go badly in future endeavors."
 
Last edited:
B

bondfish

Guest
Yes I have the comma in my code between the y and object, just miss typed it here, also I tried being persistent and didnt work. I knew that keeping it true would create more, but I just wanted to see if it would even create it
 
B

bondfish

Guest
Nothing works from the suggestions has anyone ever made a character selection? even the videos on youtube are bad and use methods that I am not using
 
D

Docker

Guest
Well you haven't exactly given us much to diagnose the problem with, and what you did give is riddled with errors and bad practices...
 

rIKmAN

Member
Yes I have the comma in my code between the y and object, just miss typed it here, also I tried being persistent and didnt work. I knew that keeping it true would create more, but I just wanted to see if it would even create it
If it is creating it, it is creating it in the room you leave straight away so of course if isnt going to be in the new room.

Use room_instance_add before you change rooms as I said earlier, or set a global variable upon selection and then in the new room check this and 'instance_create' whatever character you need to based on the global variable.

You are doing something wrong if it isn't working.
 

Posh Indie

That Guy
Nothing works from the suggestions has anyone ever made a character selection? even the videos on youtube are bad and use methods that I am not using
I would not be so quick to judge methods if yours is not working. @rIKmAN's response is the only thing that makes sense to solve your problem from what we have been given. It would help if we had your actual code instead of your butchered retyping of it (It is impossible to tell what is wrong with your code if we have code that does not reflect exactly what you are using).

There is no point in trying to help you if you provide us with minimal details and then insult our intelligence when there is not enough information to fix your mistakes. I have actually done character selection and creation numerous times.

My last bit of advice? Maybe use the "bad" methods on Youtube. They may be "bad", but they actually work and that is the important part.
 
B

bondfish

Guest
I would not be so quick to judge methods if yours is not working. @rIKmAN's response is the only thing that makes sense to solve your problem from what we have been given. It would help if we had your actual code instead of your butchered retyping of it (It is impossible to tell what is wrong with your code if we have code that does not reflect exactly what you are using).

There is no point in trying to help you if you provide us with minimal details and then insult our intelligence when there is not enough information to fix your mistakes. I have actually done character selection and creation numerous times.

My last bit of advice? Maybe use the "bad" methods on Youtube. They may be "bad", but they actually work and that is the important part.
When did I insult anyone? just said none of them worked. and if i did im sorry im just frustrated And how did you do your character selection?
 
B

bondfish

Guest
Here is the spawner code
Code:
//Create
//razor is a character
global.razor = false;

//Step
if(global.razor = true){
room_instance_add(global.razor,x,y,obj_razor); 
}
Here is the pointer or the object that selects the character.
Code:
//Step

up = keyboard_check_direct(vk_up);
down = keyboard_check_direct(vk_down);
enter = keyboard_check_direct(vk_enter);

if (up) {

action_move_to(128,224);
}

if(down)
{

action_move_to(128,340)

}
if(instance_place(x,y,obj_pickrazor)){
if(enter){
global.razor =true;
room_goto(room_2);

}

}
I put the spawner in both rooms(selection and room2), and have it on persistent
 
D

Docker

Guest
If global.razor is the character detection variable then why is it the first parameter in room_instance_add? that is meant to be the room index where you want it added
 
B

bondfish

Guest
e rooms a
If it is creating it, it is creating it in the room you leave straight away so of course if isnt going to be in the new room.

Use room_instance_add before you change rooms as I said earlier, or set a global variable upon selection and then in the new room check this and 'instance_create' whatever character you need to based on the global variable.

You are doing something wrong if it isn't working.
Thank you that worked, missed reading over when you said it had to be set in the room before, you da man
 
Top