Fangames > Programming Questions

toggling player.frozen in Gamemaker Studio

(1/2) > >>

RandomFangamer:
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: ---if room = rBossCastle{
alarm[1] = 1*room_speed
player.frozen = true
}

--- End code ---

but when I enter rBossCastle this error comes up


--- Code: ---######################################################################################
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
######################################################################################

--- End code ---

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

ilvpag:
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:

--- Quote ---have you tried creating the player at the same time as you set player.frozen equal to true?
--- End quote ---
I don't know what you mean by that
Both playerStart and the object are in the room at the start.

ilvpag:
try removing the playerStart object and use instance_create() to create the player, the code would look something like this:


--- Code: ---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
}
--- End code ---

klazen108:
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:

Navigation

[0] Message Index

[#] Next page

Go to full version