Create an object during Quest

F

FedeDyna

Guest
Greetings,

I am new with game maker and I try to make a simle rpg test game. I want to create an object in a specific location of the map IF the player interact with specific NPC.

To do that I was following a youtube instructional video but I discovery a bug on it. I will post here the code I wrote inside the obj_quest:

Create event:
depth = -y ; //Depth Correction
active = false; // if the quest is active or not


Step event:
if(GameState.switches[? "quest_started"] == true){ // if the quest start then create the object
active = true;
}

Collision with player:
GameState.switches[? "quest_gotObject"] = true;
instance_destroy();


Draw:
if(active == true){
draw_self();
}

I marked the object obj_quest as a sensor, visible and I used physics. The idea, as far as I understand, is to place the object in the room and when the player interact with the NPC, quest_started becames true, thus the object is drawn. Then, when the player collide with it the object is destroyed and the quest is terminated (quest_gotObject=true).


Problem: if I place the object inside the room, even if it is drawn only when active is equal to true, I can be able, passing on it, to collide with it :O ! Thus the quest is terminated...


Thus my question is, how can I create the object obj_quest only if the quest starts??

A bandind fix could be:

Step event:

if(GameState.switches[? "quest_teaparty_started"] == true){
event_perform(ev_collision,obj_Hero);
active = true;
}


but it is not working :) ... Could some one help me, please?


 

Jakylgamer

Member
just make a "dummy" object that has no interaction with the player, then when the quest is active
change that instance to the real object.
example:
inside "dummy" object step:
Code:
if quest_active == true {
   instance_change(quest_object,true);
}
 
Top