GameMaker: Studio

GameMaker: Studio

View Stats:
My objects won't bloody move.
Long story short, when a certain input is entered in the game, I have it so the code "obj_monster.x += 64;" runs, to move it 64 pixels to the right. I thougt it would be simple, but the problem is whenever I perform the input the object does not budge an inch, and I have no clue why. Is there a setting or something that I've missed? Please reply ASAP.
< >
Showing 1-9 of 9 comments
Almond Meal Oct 9, 2017 @ 2:23am 
I am wondering if it is colliding with a solid object. When an object collides with a solid object it is immediately returned to its previous location. Is the game a platformer? If so, what is the code for when the object lands. Also, if the object is in the air does it move then?
LittleFieryOne Oct 9, 2017 @ 10:16am 
Originally posted by Almond Meal:
I am wondering if it is colliding with a solid object. When an object collides with a solid object it is immediately returned to its previous location. Is the game a platformer? If so, what is the code for when the object lands. Also, if the object is in the air does it move then?
It's not a platformer. It's more of a very basic board game I'm making for a class. Basically, the game askes the player a question (using get_string). If the player answers right, both the player piece and the enemy piece move one space right. If wrong, only the enemy piece moves, bringing it closer to the player. I don't think it's colliding with an object, since I set both pieces to different depths than the spaces.
Almond Meal Oct 9, 2017 @ 4:24pm 
The depth is irrelevant for the collision, instances will collide even if their depths are set thousands apart. Are the spaces objects? If so, are they set to solid? If so, does it need to be?
Let me know how this turns out and if this is not the issue and we’ll look into it further.
LittleFieryOne Oct 9, 2017 @ 6:17pm 
Originally posted by Almond Meal:
The depth is irrelevant for the collision, instances will collide even if their depths are set thousands apart. Are the spaces objects? If so, are they set to solid? If so, does it need to be?
Let me know how this turns out and if this is not the issue and we’ll look into it further.
The spaces are objects, as well as the pieces, but nothing is set to solid.
Almond Meal Oct 9, 2017 @ 6:46pm 
Alright, in that case I am wondering if there is an issue with the code that leads up to the movement code. Particularly where it checks whether the answer the player gives is correct or not. We need to find where the problem lies before we can fix it. What I would do in this scenario is put in something like show_message(“Answer is correct, move both”) with the code that moves the pieces. If the message appears it means that coding is fine and something is hindering the pieces. If the message does not appear it means something is wrong in the code and the movement of the pieces is never called.
You could also put in the movement code into a key press event by itself (without the checking of answers) to see if the pieces will move at all.
LittleFieryOne Oct 9, 2017 @ 7:02pm 
Originally posted by Almond Meal:
Alright, in that case I am wondering if there is an issue with the code that leads up to the movement code. Particularly where it checks whether the answer the player gives is correct or not. We need to find where the problem lies before we can fix it. What I would do in this scenario is put in something like show_message(“Answer is correct, move both”) with the code that moves the pieces. If the message appears it means that coding is fine and something is hindering the pieces. If the message does not appear it means something is wrong in the code and the movement of the pieces is never called.
You could also put in the movement code into a key press event by itself (without the checking of answers) to see if the pieces will move at all.
I already have a message that appears when the player guesses incorrectly right above the code that's supposed to move the object. That's been working, so it must be the piece itself. However, I commented out all the code I wrote for a moment and only added a key pressed even which would move the object when I pressed "right", and that worked. Any ideas?
Thanks for the help, by the way.
Almond Meal Oct 9, 2017 @ 8:45pm 
It does seem like something the problem lies somewhere in the part you commented out.
It seems strange that it would show the message but not run the movement code. Personally I would run another message after the movement code as well to see if it goes all the way through.
The only things I can think of that might cause something like this is that the code is calling for an object that is not there (a whole object, not an instance else an error would appear) or the wrong object. Since you got it to move with the altered code, check to see if both the codes are EXACTLY the same.
But all of this is guess work, I think at this point I am going to need to see the code to find what the issue is. If you wouldn’t mind, can you post the code here?
LittleFieryOne Oct 10, 2017 @ 7:03am 
EDIT: Oh dear God I'm an imbecile. It just hit me why this wasn't working. The room doesn't draw itself once a question is answered, so the pieces don't have a chance to update their positions. At least that's my guess. I suppose I'll have to redo the code to fix that. I'm so sorry for wasting your time. Thank you for all the help. See ya (unless I'm wrong and it still doesn't work, in which case I'll probably come back here.

Old Message: Yeah, I'll post the code right here. The code I've mainly been focusing on is at the bottom. I moved the movement code before the message, and it still doesn't appear to work. Gamemaker doesn't seem to skip over the line either, since in debug mode it went over it just fine. It's like it just ignores it. See what you think.

while (global.firststep == 1) //This is only for the room to draw itself before asking the question. { while (global.question1 == 0) //This prevents it from asking the same question twice. { global.answer1 = get_string("Question 1: What is something we see every day, something with niether weight nor mass, and is not even considered matter, that exists in both the brightest and darkest of places?", ""); if (global.answer1 = "light") { obj_player.x =+ 64; //This moves the player and the monster. obj_monster.x =+ 64; global.question1++; get_string("Correct! You may continue...", ""); while (global.question2 == 0) { global.answer2 = get_string("Question 2: Name a group of elder beings that sometimes live for less than twenty years, others more than a thousand. They do not move or speak; they only stare at the sun and reach for the sky",""); if (global.answer2 == "trees") { global.question2++ obj_player.x += 64; obj_monster.x += 64; while (global.question3 == 0) { get_string("Correct! You may continue...", ""); global.question3++ global.answer3 = get_string("Question 3: What do you balance against a supsected witch?", ""); } if (global.answer3 == "duck") { obj_player.x += 64; obj_player.x += 64; get_string("You made it to the end! Good job!", ""); } else { get_string("Incorrect... the mosnter approaches.", ""); obj_monster.x += 64 } } else { get_string("Incorrect... the monster approaches.", ""); obj_monster.x += 64 } } } else { obj_monster.x += 64; //This is what I"ve been focusing on mainly, since it's faster to give a wrong answer. get_string("Incorrect... the monster approaches.", ""); } } } while (global.firststep == 0) { global.firststep++; }
Last edited by LittleFieryOne; Oct 10, 2017 @ 4:14pm
Almond Meal Oct 10, 2017 @ 9:41pm 
I am glad that you managed to work it out. Although you already found it, I can see that it runs through all the questions in the one step and therefore would wait until every question is answered before moving. I can certainly help you fix it and already have a number of solutions if you need it but it does sound like you know what to do so I’ll let you do it your way. I am always glad to help so feel free to ask.
< >
Showing 1-9 of 9 comments
Per page: 1530 50

Date Posted: Oct 9, 2017 @ 12:08am
Posts: 9