Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » 2D Game (Top View) Glitchy Character - Goes through Walls
- LegoCreep
-
24 posts
2D Game (Top View) Glitchy Character - Goes through Walls
On my most recent game, the character seems to glitch through the walls/move without command until not touching the color black if you are pressing one key, and then switch to another. I don't want my character to leave the area. My game is 2D (top view) and a Prison Break game. Hope you can help! Thanks, LegoCreep.
Last edited by LegoCreep (May 19, 2015 21:41:46)
- LegoCreep
-
24 posts
2D Game (Top View) Glitchy Character - Goes through Walls
I kind of already have that in my script, and it isn't a side view 2D game, it's a top view. I would check it out so you can see for yourself. Thanks for the help though! Try using:
- GuyOfCoding
-
66 posts
2D Game (Top View) Glitchy Character - Goes through Walls
Interesting script setup. I say that you probably forgot to have it realize that even when the character is going backwards, it still has to get put back to mapX or mapY
- LegoCreep
-
24 posts
2D Game (Top View) Glitchy Character - Goes through Walls
Hmm? I don't understand what you mean. Interesting script setup. I say that you probably forgot to have it realize that even when the character is going backwards, it still has to get put back to mapX or mapY
- LegoCreep
-
24 posts
2D Game (Top View) Glitchy Character - Goes through Walls
Since the character isn't moving at all (at least it's sprite) and only the map is ACTUALLY moving you are confusing me.Hmm? I don't understand what you mean. Interesting script setup. I say that you probably forgot to have it realize that even when the character is going backwards, it still has to get put back to mapX or mapY
- GuyOfCoding
-
66 posts
2D Game (Top View) Glitchy Character - Goes through Walls
What I mean is that I don't think you programmed it to move the character back even when walking backwards into the wall. If not that, then what also could have been the problem is that instead of moving to where there is no wall, it continues to run a script telling it to go into the wall.
- LegoCreep
-
24 posts
2D Game (Top View) Glitchy Character - Goes through Walls
How should I make that script then? What I mean is that I don't think you programmed it to move the character back even when walking backwards into the wall. If not that, then what also could have been the problem is that instead of moving to where there is no wall, it continues to run a script telling it to go into the wall.
- LegoCreep
-
24 posts
2D Game (Top View) Glitchy Character - Goes through Walls
I can't figure out how to make the script. What I mean is that I don't think you programmed it to move the character back even when walking backwards into the wall. If not that, then what also could have been the problem is that instead of moving to where there is no wall, it continues to run a script telling it to go into the wall.
- GuyOfCoding
-
66 posts
2D Game (Top View) Glitchy Character - Goes through Walls
Idk. Try tweaking each of your scripts and you should be able to find what's wrong.
- mekizmo
-
51 posts
2D Game (Top View) Glitchy Character - Goes through Walls
It seems that the problem occurs when you are in a corner, and touch black on two different sides. Assume you are in a bottom left corner, and want to move left. Your code says:
What I suggest is that the color you use for the horizontal walls should be slightly different from the one that you usee for vertical ones.
Since you are touching black, you move 1 step right; but since you are still touching black, you keep moving more and more steps, regardless whether there's another wall on your right.
What I suggest is that the color you use for the horizontal walls should be slightly different from the one that you usee for vertical ones.
Last edited by mekizmo (May 19, 2015 23:59:18)
- LegoCreep
-
24 posts
2D Game (Top View) Glitchy Character - Goes through Walls
Oh yeah! Never though of that! Thanks! It seems that the problem occurs when you are in a corner, and touch black on two different sides. Assume you are in a bottom left corner, and want to move left. Your code says:Since you are touching black, you move 1 step right; but since you are still touching black, you keep moving more and more steps, regardless whether there's another wall on your right.
What I suggest is that the color you use for the horizontal walls should be slightly different from the one that you usee for vertical ones.
- GuyOfCoding
-
66 posts
2D Game (Top View) Glitchy Character - Goes through Walls
How do I become a Scratcher?
- Discussion Forums
- » Help with Scripts
-
» 2D Game (Top View) Glitchy Character - Goes through Walls