GMS 2 Character not visible

Discussion in 'Programming' started by Sqoler, Apr 16, 2019.

  1. Sqoler

    Sqoler Member

    Joined:
    Apr 16, 2019
    Posts:
    6
    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.
     
  2. Megax60

    Megax60 Member

    Joined:
    Jun 22, 2017
    Posts:
    67
    maybe its the draw event that is preventing the object from drawing?
     
  3. Sqoler

    Sqoler Member

    Joined:
    Apr 16, 2019
    Posts:
    6
    I am new to GMS2, but what is the draw event? I don't think I have one active
     
  4. Megax60

    Megax60 Member

    Joined:
    Jun 22, 2017
    Posts:
    67
    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
     
  5. Megax60

    Megax60 Member

    Joined:
    Jun 22, 2017
    Posts:
    67
    i know its a bit annoying the explosions, but i use it for cases like this
     
  6. Sqoler

    Sqoler Member

    Joined:
    Apr 16, 2019
    Posts:
    6
    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.
     
  7. Megax60

    Megax60 Member

    Joined:
    Jun 22, 2017
    Posts:
    67
    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?
     
  8. Sqoler

    Sqoler Member

    Joined:
    Apr 16, 2019
    Posts:
    6
    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
     
  9. Megax60

    Megax60 Member

    Joined:
    Jun 22, 2017
    Posts:
    67
    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
    }
     
  10. Sqoler

    Sqoler Member

    Joined:
    Apr 16, 2019
    Posts:
    6
    I tried it but nothing happened. Still the same problem...
     
  11. Megax60

    Megax60 Member

    Joined:
    Jun 22, 2017
    Posts:
    67
    well, i did what i could, sry, study some gml, with time you'll be able to solve some or many problems yourself
     
  12. Sqoler

    Sqoler Member

    Joined:
    Apr 16, 2019
    Posts:
    6
    Well, if anyone could help. This is for a school project actually
     
  13. Corey

    Corey Member

    Joined:
    Apr 8, 2019
    Posts:
    19
    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: Apr 18, 2019 at 1:54 PM

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice