GameMaker My script is not persistant

S

Sroft

Guest
So my script is attached to my player object and it changes sprite animations. for example my player runs unarmed and picks up a gun that gun has different animations with it and of course the player can not fire.
But when I leave the room the animation is back to unarmed animations. Any advice appreciated
 

Smiechu

Member
It was already discussed in another thread of yours, but apparently you missed it or simply ignored...

Your player object needs to be persistance and must have a variable defining which type of weapon he holds.
Your script and/or rest of the code must run based on the information stored in that variable.
 
S

Sroft

Guest
It was already discussed in another thread of yours, but apparently you missed it or simply ignored...

Your player object needs to be persistance and must have a variable defining which type of weapon he holds.
Your script and/or rest of the code must run based on the information stored in that variable.
I didn't really ignore it just the thread just went dead and I tried solving this problem for 3 days(ish)
but thank you for responding!
anyway I have made my object persistent like what other people have suggested but still dose not work
but what do you mean which type of weapon he holds
(sry im still a noob to coding starting self teaching this summer)
Thanks again
 

Smiechu

Member
Ok... back to the roots...

Do you have a state machine implemented in your code to manage all the animations and all other things happening with your player?
No - implement it and your problem will be solved.
Yes - review your code step by step and try to find flaws in your logic...
 
S

Sroft

Guest
Ok... back to the roots...

Do you have a state machine implemented in your code to manage all the animations and all other things happening with your player?
No - implement it and your problem will be solved.
Yes - review your code step by step and try to find flaws in your logic...
Thanks for responding!
I do indeed have state machine and I tried to see if there was anything wrong with it. but alas I couldn't find anything!(I don't know if i'm dumb and there is a mistake that i missed, it would help me a ton if you look over this and yes the object it persistent)
PObject
create
//weapons
enum WEAPONS_MODE
{
HANDS,
PLASMA
}
weapons = WEAPONS_MODE.HANDS
step
//Animation(complex)
switch (weapons)
{
case WEAPONS_MODE.HANDS:
{
Unarmed();
break;
}
case WEAPONS_MODE.PLASMA:
{
Plasmagun();
break;
}
}

Unarmed
if (!place_meeting(x,y+1,WObject))
{
sprite_index = PlayerA;
image_speed = 20;
if (sign(vsp) > 20) image_index = 1; else image_index = 1;
}
else
{
image_speed = 1;
if (hsp == 0)
{
sprite_index = Player;
}
else
{
sprite_index = PlayerR;
}
}
if (hsp != 0) image_xscale = sign(hsp);

Plasmagun
//Animation
if (!place_meeting(x,y+1,WObject))
{
sprite_index = sPGunPlasmaA;
image_speed = 20;
if (sign(vsp) > 20) image_index = 1; else image_index = 1;
}
else
{
image_speed = 1;
if (hsp == 0)
{
sprite_index = sPGunPlasma;
}
else
{
sprite_index = sPGunPlasmaR;
}
}
if (hsp != 0) image_xscale = sign(hsp);

Thank you so much
 

Smiechu

Member
Don't see anything... is there any other place where you set the weapons state??

P.S.
Technical issue - please follow the forum rules, and post the code in code tags...
 
S

Sroft

Guest
Don't see anything... is there any other place where you set the weapons state??

P.S.
Technical issue - please follow the forum rules, and post the code in code tags...
PObject collision event OPlasmagunPickup
weapons = WEAPONS_MODE.PLASMA
Maybe this is wrong and makes it reset when the player picks up the gun but I doubt it
What im thinking is making the player with the plasmagun its own object and change objects when colliding with the gun but I think id prefer to not make to many object but im kinda running out of idea's. What do you think?
Thanks for helping!
 

TheouAegis

Member
Make sure you don't have a player object in every single room. If you're making a player object persistent, there should only be one player object in the entire game.
 
S

Sroft

Guest
Make sure you don't have a player object in every single room. If you're making a player object persistent, there should only be one player object in the entire game.
turns out there was something wrong with my transitions room to room huh
anyway thanks for help!
 
N

NeZvers

Guest
You can also use global variable to save in room end and read in room start, so you won't need the player to be persistant.
 
Top