• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

How to make variables carry over?

B

BladeGamez

Guest
I am starting to use custom variables. I just made a new variable and made it global. I went into a different object to use the variable so that when it increases in value it changes the arrow controls to WASD, but the error code says that it is not set! I'm so lost when it comes to these things. Anyone have any advice? Thanks in advanced!
 
B

BladeGamez

Guest
Show us your code!
The variables for my character:
grav = 0.35;
hsp = 0;
vsp = 0;
jumpspeed = 13;
movespeed = 7;
global.movv = 0;


hp = 100;

global.up=vk_up;
global.down=vk_down;
global.left=vk_left;
global.right=vk_right;

Player controls:
if movv = 0
then
{
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check(vk_up);
}

if movv = 1
then
{
key_right = keyboard_check(ord("D"));
key_left = -keyboard_check(ord("A"));
key_jump = keyboard_check(ord("W"));
}

movv change:
///make movv change. Movv actually stands for movement value? Redundent, I know
if keyboard_check_released(ord('C'))
{
movv += 1;
}


the movv change is still a work in progress and is more of like a placeholder until I can figure out how to carry variables
 

DT Mark

Member
Make sure you reference that global variable like so:
Code:
if global.movv == 0
and not like so:
Code:
if movv == 0
 
B

BladeGamez

Guest
Make sure you reference that global variable like so:
Code:
if global.movv == 0
and not like so:
Code:
if movv == 0
THANKS SO MUCH. I can't believe how stupid I was! thanks for leading me in the right direction!
 
Top