Scorcher24 2. okt, 2012 @ 9:59pm
Sprites continue to move after collision
Difficult to explain.

I have a playersprite that consists out of 3 sprites, arranged next to each other. All 3 Sprites are controlled by the middle sprite that handles the movement and moves the sprites left and right with it. When either the left sprite or the right sprite hit the level boundary, which is represented by an object called objWallSide, all 3 sprites are supposed to stop immediatly.

But they don't. The middle sprite continues to move until the middle sprite hits objWallSide, pushing the left and the right sprites on the same position where the middle one is. And yes, I added a movement modifier for all sprites in the collision routine.

Anyone got any hints?^^

Viser 1-9 av 9 kommentarer
< >
M.S.T.O.P. 3. okt, 2012 @ 1:49am 
How are you controling the movements? Using keyboard events? If so, are you setting the speed and direction of each object within those keyboard events?
Scorcher24 3. okt, 2012 @ 6:27am 
Yes, thats what I do. On Keypress I start moving it and and on key release I stop it.
Noam Chimpsky 3. okt, 2012 @ 6:30am 
I never used this software, but is there a way to get the code of your game? If so, you should probably post it. Or post anything that is describing the relationships between your objects and your logic. Some downsides of Game Maker Studios are becoming apparent...
Scorcher24 3. okt, 2012 @ 6:35am 
Well there is no code, otherwise I would post some :D.
I know programming and that's not my first prototype, but yeah, thats a downside of it :).
But maybe that screenshot hels: http://imgur.com/a/JEaiU
It contains the visual scripts for objPlayerMiddle Keypress Event and the collision code of objWallSides.


The "Start moving in a direction" command in the Keypress Event is moving all 3 sprites into one direction when the key is pressed, the same command with parameter 0 is issued when the key is released or when either the left or the right sprite hit the wall.
Sist redigert av Scorcher24; 3. okt, 2012 @ 6:37am
Mizipzor 3. okt, 2012 @ 6:52am 
If a collision stops the sprite and a key press moves the sprite what happens if you hold down the key while the collision occurs? Just a guess but I think the key press takes precedence in your case. Maybe add a check after the key press but before you move that makes sure its valid for it to start moving.
Scorcher24 3. okt, 2012 @ 6:54am 
I tried that, it might prevent the sprite from moving at all after I touched the wall, since I did not find a "collision over" event. Also, even with setting a variable, this happened. Is there no way to just set some level boundaries where the player cannot move beyond? You can do that in Torque2D which I own.
Sist redigert av Scorcher24; 3. okt, 2012 @ 7:05am
M.S.T.O.P. 3. okt, 2012 @ 12:48pm 
I think I got it. As mizipzor said, you need to check if there isn't a wall in the way before you move. You can do that by using a "Check Object" action in the keyboard events.

This code gets the desired results for me:
http://i.imgur.com/0IG7F.png
Scorcher24 3. okt, 2012 @ 4:48pm 
Thanks mate :). I still think the world limits from Torque2D are cooler in that regard.
M.S.T.O.P. 3. okt, 2012 @ 9:10pm 
There is an event called "Intersect Boundary" that triggers whenever an object intersects the boundaries of a room. You could tell the objects to stop in that event. Functionally, I think it's same as what you're doing, except you don't have to manually wall off every room you create.
Viser 1-9 av 9 kommentarer
< >
Per side: 15 30 50
Dato lagt ut: 2. okt, 2012 @ 9:59pm
Innlegg: 9