Separate object problem

Hello, I’m trying to make the player sprite to be bounded within the camera. So I created 4 blank sprites and used them as invisible walls at the edges of the camera. I initially had a problem with the right bound, and I solved this by moving the sprite within the camera (even though I don’t know why, but it works).

I also had a second problem, which I did not exactly resolve: when the player collided with the bound it kinda got stuck, like it retained the speed in that direction and waited for it to became 0. So I added the “Change the speed on the * axis to 0” (* depends on which bound you touch, Up and Down = Y axis, Right and Left = X axis) and now it doesn’t get stuck anymore BUT something weird happens: when a speed gets applied on the other axis it won’t decrease.
I’ll explain with an example: if I’m going right, and I touch the right bound the player won’t get “stuck” and will stop but if I keep pressing Right and press for an instance Up/Down the player will go Up/Down without stopping (until it, obviously, touches the Up/Down bound).

I’m kinda confused of why this happens and can’t figure out how to solve it, any help?

Hi, I guess without seeing your events this might be difficult for anyone to answer. It sounds, however, as if the “Room-based camera movement” - extension could be helpful.

It’s not a camera problem, it’s a sprite problem

I understand. I just suggested the extension to give you some inspiration to solve your problem differently. Using sprites as boundaries is one method but you could also just use the screen width and height to limit the movement of your player.
For solving your problems with the sprites, it would be helpful if you could post a screenshot of your events.

right now it’s this
how do you make boundaries with height and width?

For the events you could simplify them, e.g. like (I just have one border sprite that is placed 4 times in the scene and two times rotated).

The sliding effect along the border which you don’t want is only slightly there, so maybe that’s already okay.

This is because you don’t limit the movement along the y-axis (or in the case of the other borders on the x-axis). The player-sprite collides and is separated from the border-sprites, it cannot move in that direction but it can slide along the border on the other axis.

You could do something like this:

In this case the movement on the x-axis is limited but the player is sliding along the y-axis.

Ok, great explaining, thank you, for real.

Maybe I’ll also try the second solution. I’ll try to add a “change the speed on the * axis to 0” where * equals to the other axis (e.g. if you go left the Y axis gets to 0). Do you think it could work?

Yes, I’d try that. It’s anyway trial and error to get a result that is acceptable for the specific situation.

1 Like