GameMaker Character not visible

S

Sqoler

Guest
I made a warp object for my 3/4 RPG game, but when my character uses the warp, it becomes invisible. The 'camera' does switch between rooms, and the character does technically move (I can go back to the previous room), but I can't see the sprite. Persistent has already been turned on.

This is the code for the warp object:

Create:
var targetRoom, targetX, targetY;

Collision:
room_goto (targetRoom);
objplayer.x = targetX;
objplayer.y = targetY;

Creation code:
targetRoom = room_2;
targetX = 416;
targetY = 64;

Please let me know what I did wrong, or how I can fix this.
 

Megax60

Member
well, if you dont have the draw event just ignore it, you must first check if the character moves to the right position.
set this on the player step event:

effect_create_above(ef_explosion,x,y,3,c_red);
you can remove it later

if you run the game and don't see any explosion, its because the camera is not even following the player, but if you see an explosion, its because something made the player invinsible.

just to be sure set this on the step event,
image_alpha = 1;

with this the player should always be visible, but if its not, its because its outside the camera
 
S

Sqoler

Guest
well, if you dont have the draw event just ignore it, you must first check if the character moves to the right position.
set this on the player step event:

effect_create_above(ef_explosion,x,y,3,c_red);
you can remove it later

if you run the game and don't see any explosion, its because the camera is not even following the player, but if you see an explosion, its because something made the player invinsible.

just to be sure set this on the step event,
image_alpha = 1;

with this the player should always be visible, but if its not, its because its outside the camera
First off, thanks already.
I tired both codes, but the both did nothing. Something to add maybe is that I have a small room which fits on the screen. That means I dont need my camera to follow the player, it just shows the room. When I walk to the right of my screen, where I put the warp object, the screen switches to the second room. If I continue to press A (left) I will eventually return to the first room, because I have a warp in the sond room as well, but my character is not visible on screen.
 

Megax60

Member
you are saying you put the first code in the player step event, and didn't see any changes? thats weird, you should have seen a red explosion, are you sure the player is inside the camera?
 
S

Sqoler

Guest
you are saying you put the first code in the player step event, and didn't see any changes? thats weird, you should have seen a red explosion, are you sure the player is inside the camera?
I think it is. I did put my object in the first room, but not the rooms after. Is this wrong? I do think my camera is static, it doesnt move, only the rooms switch. And do I have to put the explosion code on the first line? Because I put it on the last one
 

Megax60

Member
you can put the explosion in wherever step line you want, in this case we are using it to see where is the player.

check if the object is persistent

in the creation code of the room you want to go set:
Code:
with obj_player{
    x = whatever
    y = you want here
}
 
S

Sqoler

Guest
you can put the explosion in wherever step line you want, in this case we are using it to see where is the player.

check if the object is persistent

in the creation code of the room you want to go set:
Code:
with obj_player{
    x = whatever
    y = you want here
}
I tried it but nothing happened. Still the same problem...
 
S

Sqoler

Guest
Well, if anyone could help. This is for a school project actually
 

Corey

Member
It's possible that the background depth is lower than your player object. That would explain why you can't see your character but can operate it normally. Make sure the background depth in room_2 is a higher number than the player object and see if that works.

When new rooms are created, it'll create two layers: Instances and Background. Instances will be at a depth of 0, while Background is depth 100. You'll have to change the depth number to a higher number than your player if you want the player on top of the background.

To change depth, go to your new room, open Layer View, click on the background and at the bottom, change depth to 10000.
 
Last edited:
Top