Author Topic: toggling player.frozen in Gamemaker Studio  (Read 2182 times)

RandomFangamer

  • Cherry Eater
  • Posts: 71
  • Pico Pico Piiiiiii
  • OS:
  • Windows 8.1/Server 2013 Windows 8.1/Server 2013
  • Browser:
  • Chrome 44.0.2403.107 Chrome 44.0.2403.107
    • View Profile
  • Playstyle: Keyboard
toggling player.frozen in Gamemaker Studio
« on: July 28, 2015, 12:43:23 PM »
In Klazen's engine I'm trying to make a short cutscene where the player is frozen and then unfrozen.
So in an object's create event I have the following written out
Code: [Select]
if room = rBossCastle{
alarm[1] = 1*room_speed
player.frozen = true
}

but when I enter rBossCastle this error comes up

Code: [Select]
######################################################################################
FATAL ERROR in
action number 1
of Create Event
for object objBossIntroSnoop:

Unable to find any instance for object index '33'
 at gml_Object_objBossIntroSnoop_CreateEvent_1 (line 3) - player.frozen = true
######################################################################################

Could anyone tell me why this is happening, even though this worked in gamemaker 8.1?




:ItsBoshyTime: o o o o o :denProgress: o o o o o :paraKid:

ilvpag

  • Guest
Re: toggling player.frozen in Gamemaker Studio
« Reply #1 on: July 28, 2015, 01:34:17 PM »
it seems to be executing the code before the player exists, did you place the playerStart into the room? and if you did, have you tried creating the player at the same time as you set player.frozen equal to true?

RandomFangamer

  • Cherry Eater
  • Posts: 71
  • Pico Pico Piiiiiii
  • OS:
  • Windows 8.1/Server 2013 Windows 8.1/Server 2013
  • Browser:
  • Chrome 44.0.2403.107 Chrome 44.0.2403.107
    • View Profile
  • Playstyle: Keyboard
Re: toggling player.frozen in Gamemaker Studio
« Reply #2 on: July 28, 2015, 02:29:47 PM »
Quote
have you tried creating the player at the same time as you set player.frozen equal to true?
I don't know what you mean by that
Both playerStart and the object are in the room at the start.




:ItsBoshyTime: o o o o o :denProgress: o o o o o :paraKid:

ilvpag

  • Guest
Re: toggling player.frozen in Gamemaker Studio
« Reply #3 on: July 28, 2015, 02:51:25 PM »
try removing the playerStart object and use instance_create() to create the player, the code would look something like this:

Code: [Select]
if room = rBossCastle{
alarm[1] = 1*room_speed
instance_create(x+17, y+23, player) //replace x and y with the positions where you want the player to spawn
player.frozen = true
}

klazen108

  • Administrator
  • The Kid
  • Posts: 286
  • your a kid now your a squid now
  • OS:
  • Windows 8.1/Server 2013 Windows 8.1/Server 2013
  • Browser:
  • Chrome 44.0.2403.89 Chrome 44.0.2403.89
    • View Profile
    • Delicious-Fruit
  • Playstyle: Keyboard
Re: toggling player.frozen in Gamemaker Studio
« Reply #4 on: July 28, 2015, 03:06:04 PM »
The playerStart object creates the player using a Room Start event, which happens after all instances in the room have completed their Create events. This means that when you try to freeze the player, the playerStart object hasn't made one yet! And if you moved your code to the Room Start event, there's no guarantee that the playerStart object will have done it's code first. So yes, you'll need to create the player yourself in your cutscene code, just like sandsky pointed out. (Or you could make a new playerStart object that does the same thing as the normal one, except also sets frozen=true)

P.S. I approve of that object's name :Kappa:

RandomFangamer

  • Cherry Eater
  • Posts: 71
  • Pico Pico Piiiiiii
  • OS:
  • Windows 8.1/Server 2013 Windows 8.1/Server 2013
  • Browser:
  • Chrome 44.0.2403.107 Chrome 44.0.2403.107
    • View Profile
  • Playstyle: Keyboard
Re: toggling player.frozen in Gamemaker Studio
« Reply #5 on: July 29, 2015, 04:18:16 PM »
Thanks, the intro works now!  :IceFairy:




:ItsBoshyTime: o o o o o :denProgress: o o o o o :paraKid: