• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED colission with the npc to open text box, but...

S

ShadowLenz

Guest
I have a "obj_interact" with:

- Create event:
image_speed = 0;
depth = -y;
collision = true;

And having as "children" the ---> obj_npc
the npc has the: event_inherited (); on the create event

And the: protagonist_object
having (depth, collision variables on the step even so they are seated)

and when collides with obj_npc:

if keyboard_check_pressed (ord('E') and instance_place (x, y,obj_npc)<3)
{
instance_create (view_xview +395,view_yview +480,objdialog2);
instance_create (view_xview +660,view_yview +565,click_it);
instance_create (view_xview +125,view_yview +498,circle_obj);
instance_create (view_xview +105,view_yview +465,face_brennan);
instance_change (obj_stay,false); <---- this means de characater changes onto another protagonist_object to prevent a massive opening of text's box
}


BY FAR ALL GOOD.

The moment to sweat is when it collides, it opens the dialog well and others but when I close the text box, the character is still in front of the npc and it continues to open, I am locked next to him and I do not know how to prevent it from happening, the obj_npc has his mask modified but still happening.

Thanks in advance for who helps me.
 

kburkhart84

Firehammer Games
Wait...if you are already in the collision event, you already have confirmation that the object collided with something. So, why are you then doing instance_place() at all? I understand if you want to check if the keyboard key is pressed at the time, but why re-verify the collision?

Also, does your obj_stay object have any code to change back to the original protagonist object once the dialog is done? If not, it won't move like that object. Remember you are changing the instance to obj_stay, so it won't be running any code that isn't on THAT object at that point.
 
S

ShadowLenz

Guest
Wait...if you are already in the collision event, you already have confirmation that the object collided with something. So, why are you then doing instance_place() at all? I understand if you want to check if the keyboard key is pressed at the time, but why re-verify the collision?

Also, does your obj_stay object have any code to change back to the original protagonist object once the dialog is done? If not, it won't move like that object. Remember you are changing the instance to obj_stay, so it won't be running any code that isn't on THAT object at that point.
Yes, when i press to close the text box the obj_stay changes to the principal character again but still stuck with obj npc and proceeds to open again the text box
 
S

ShadowLenz

Guest
Are you using the same key to close the text box as you are to open it?
No, when collision is confirmed and i press "E" key, the text box is created and

if keyboard_check_pressed (ord('E') and instance_place (x, y,obj_npc)<3)
{
instance_create (view_xview +395,view_yview +480,objdialog2); <---the object that draws the text box and the text
instance_create (view_xview +660,view_yview +565,click_it); <---an arrow for closing the text box
instance_create (view_xview +125,view_yview +498,circle_obj); <--- just decoration
instance_create (view_xview +105,view_yview +465,face_brennan); <--- characters face
instance_change (obj_stay,false);
}
 

kburkhart84

Firehammer Games
Yeah, but when you are closing the text box and changing the object back to the original one, what key are you using? Can I see code where the box goes away and you call instance_change() to change it back?
 
S

ShadowLenz

Guest
Yeah, but when you are closing the text box and changing the object back to the original one, what key are you using? Can I see code where the box goes away and you call instance_change() to change it back?
when character collides with the npc and press E creates the obj textbox and that obj draws all that, the "click_it" object then destroys the textbox instances and the character_stay, changes onto the character that can move(that would allow me to move again but characters stays in the same position so the event repeats again), maybe the problem its the collisions mask or the obj_int itself

putting all the scripts here its to hard 0_0U
 

kburkhart84

Firehammer Games
I just wanna see the code where you destroy the text box and change the character back. The repetition shouldn't be happening again unless you are hitting the E key again....so I want to see the code and figure out what could be causing it.

The masks should have nothing to do with because even if they are colliding you are still checking for the keypress going by the code you did show us, so there shouldn't be any need to change masks or worry about that part, that's why I questioned why you were even using instance_place() when you are already inside the collision event, and therefore already have confirmation that there is a collision. You never answered me that either.
 
S

ShadowLenz

Guest
I just wanna see the code where you destroy the text box and change the character back. The repetition shouldn't be happening again unless you are hitting the E key again....so I want to see the code and figure out what could be causing it.

The masks should have nothing to do with because even if they are colliding you are still checking for the keypress going by the code you did show us, so there shouldn't be any need to change masks or worry about that part, that's why I questioned why you were even using instance_place() when you are already inside the collision event, and therefore already have confirmation that there is a collision. You never answered me that either.
this parts is not at all a script just direct access buttons from GM [attached image]

initially the script went along with the npc and if was the npc (who is still) who collided with the protagonist, it executed that action.

It was not the protagonist who take the collison even at first, but even so the effect was still present, still stucked. So try to pass the code to the protagonist who collides with the npc
 

Attachments

kburkhart84

Firehammer Games
What is thav_obj? You mention a protagonist object but it had a different name. Note that you can't just pass code across without changing things. If you are only using D&D I may prefer to leave it to someone else who is more familiar with it. Also, I DO know that you need to be sure you are doing things correctly as far as instance vs object. All kinds of issues come up when you should be using an instance variable instead of the object name.
 
S

ShadowLenz

Guest
What is thav_obj? You mention a protagonist object but it had a different name. Note that you can't just pass code across without changing things. If you are only using D&D I may prefer to leave it to someone else who is more familiar with it. Also, I DO know that you need to be sure you are doing things correctly as far as instance vs object. All kinds of issues come up when you should be using an instance variable instead of the object name.
the protagonist is --> obj_thav. but i put in the post "protagonist" to not go around too much saying how I have written the objects in my game xd
 

kburkhart84

Firehammer Games
So in that thing in the d&d where you change instance to obj_thav...can you show me the dialog options for that specific command?
 
S

ShadowLenz

Guest
So in that thing in the d&d where you change instance to obj_thav...can you show me the dialog options for that specific command?
HI!!! after finding out how I can fix my text script, I found the answer that: I add a new event to the obj_npc ---> if I press E and then open to put scripts and paste what I already had works much better.

obj_npc on event "press E"
script:
instance_place (x, y,obj_npc)<3)
{
instance_create (view_xview +395,view_yview +480,objdialog2);
instance_create (view_xview +660,view_yview +565,click_it);
instance_create (view_xview +125,view_yview +498,circle_obj);
instance_create (view_xview +105,view_yview +465,face_brennan);
}

and for thav_obj too, press E event and in script

if (distance_to_object(obj_npc)<3)
instance_change (obj_stay,false);


works perfectly~ thanks for ALL your efforts
 
Top