Jump to content


Photo

Too many Players!?


  • Please log in to reply
7 replies to this topic

#1 CorruptionEX

CorruptionEX

    The Wistful Shadow

  • New Member
  • 52 posts
  • Version:GM8

Posted 24 April 2012 - 11:11 PM

So I have this 'Door' System, that brings players to different room depending on which 'Door' they enter, pretty self explanatory...

Unfortunately, there is one flaw:

When you RE-enter Testing_Room, it spawns two, Player_1 objects, rather than just one...

This is what I assumed:
I notice that they spawn at different coordinates, so there must be two different 'instance_create(x,y,Player_1)' lines of code that get executed in Testing_Room. One spawns at (150,150), and that is the one I want to be spawning, so it just leaves the other one, which is approximately at (50,50).
So I looked for any other line of 'instance_create(x,y,Player_1)' in any place that might be linked to Testing_Room in some way at all.
I found one line of the exact code I was looking for, but only, it doesn't make any sense where it is...
The one like, 'instance_create(50,50,Player_1)' is in the "Begin Single Player" object. This object is on the main menu, and when you left click it, it brings you to Testing_Room, and creates an instance of Player_1 at (50,50)
However, this is ONLY executed once, when the player clicks the object, and the object is ONLY located on the main menu.

Other than that line, the only other code that creates an instance of Player_1 is in the 'Door' Script, and that creates one at (150,150), so that is obviously not creating the one at (50,50)

The room is NOT checked persistent, and neither are any of the objects. (In other words, nothing is persistent.)

Anyone got any ideas?



EDIT: Also, if you can't figure out what's wrong, then maybe a way to simply limit the amount of 'Player_1' objects in a room, then that might serve as a good temporary solution.

EDIT AGAIN: While trying to fix the problem myself, and through playing around with different set ups, I'm finding that everytime you go through a door, it creates another instance, in addition to the instances it was already going to create.

Edited by CorruptionEX, 25 April 2012 - 12:23 AM.

  • 0

#2 TheouAegis

TheouAegis

    GMC Member

  • GMC Member
  • 9828 posts
  • Version:GM8

Posted 25 April 2012 - 01:21 AM

Uncheck the "Persistent" box in the player object.
  • 0

#3 creativebunch

creativebunch

    The Bunchiest

  • GMC Member
  • 893 posts
  • Version:GM:Studio

Posted 25 April 2012 - 03:01 AM

Uncheck the "Persistent" box in the player object.

The room is NOT checked persistent, and neither are any of the objects. (In other words, nothing is persistent.)

It sounds like a persistent problem, but if it was the player object would also be appearing in other rooms!

CorruptionEX you will have to post all the code related to spawning the troublesome player.
  • 0

#4 TheouAegis

TheouAegis

    GMC Member

  • GMC Member
  • 9828 posts
  • Version:GM8

Posted 27 April 2012 - 01:18 AM

Wait, so you click a button in one room, the game sends you to another room and then creates the instance in the other room? Or is it you click a button in one room, it creates the instance in another room, and then sends you to that room?

It's an important distinction, as one would require global variables (teleport to room then create instance) and the other would be the obvious cause (create instance then teleport).
  • 0

#5 CorruptionEX

CorruptionEX

    The Wistful Shadow

  • New Member
  • 52 posts
  • Version:GM8

Posted 27 April 2012 - 09:51 AM

What I was doing was that when the door was created, i set the OutputRoom, OutputX, and OutputY. When a player touched the door, P1, P2, or P3 was set as the InputPlayer.

Then while any of the three players were touching the door, it would be executing the door script. The script did nothing for as long as the 'S' key wasnt being pressed. If the touched the door, the script would say:

with InputPlayer {instance_destroy()}
room_goto(OutputRoom)
room_instance_add(OutputRoom,OutputX,OutputY,InputPlayer)

Thats not the exact code, but close to that. I have already tryed to take a different approch to doors, and i droped the multiplayer option in my game, so really, this topic should be closed :/
  • 0

#6 TheouAegis

TheouAegis

    GMC Member

  • GMC Member
  • 9828 posts
  • Version:GM8

Posted 27 April 2012 - 06:26 PM

There's your problem, as I theorized. (I said it was the obvious cause).

room_instance_add() is a PERMANENT function. Any instance added to the room will be there every time you go to that room unless you set the room as persistent.
  • 0

#7 CorruptionEX

CorruptionEX

    The Wistful Shadow

  • New Member
  • 52 posts
  • Version:GM8

Posted 29 April 2012 - 01:41 AM

There's your problem, as I theorized. (I said it was the obvious cause).

room_instance_add() is a PERMANENT function. Any instance added to the room will be there every time you go to that room unless you set the room as persistent.


thanks, i didnt know that =D
always learning new stuff....
  • 0

#8 Primoz128

Primoz128

    GMC Member

  • GMC Member
  • 308 posts
  • Version:GM:Studio

Posted 29 April 2012 - 01:47 AM

instance_exists(obj)
nuff said
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users