Camera Buttons not quite working (with images)


  • Posts: 28
I'm working on a small puzzle game where you navigate these dying zombie people out of a dungeon, and I'm working on an actor behavior that helps control the camera. The camera is just a 32x32 actor that does not collide with anything, is not affected by gravity, etc. and has a behavior that makes the camera follow it. Basically, I have 4 buttons on each side of the screen that functions when the mouse hovers over it.  All of the buttons operate with the same behavior (image attached,) and it does a few things:
-Pauses the game (except for necessary actors).
-Moves the camera actor in a direction based on the "direction" attribute, which is represented by a number ID. 1 is up, 2 is right, 3 is down, and 4 is left. Each directional button is assigned its own ID.
-When the mouse is not hovering over a button, it unpauses and stops the camera actor.
Anyways, here's the issue:
The last of the buttons that is created is the ONLY one that works. I've gotten them all to work separately by placing them on the scene in different orders. Interestingly enough, if the second to last created button shares a corner with the last created button, the second to last works in conjunction with the last, moving the camera diagonally. The second to last button does not work outside of that corner.
I apologize if this sounds confusing, but I attached some visuals that I will explain now. I have a  scene behavior that creates all of these buttons, and UP & RIGHT are the last two created, UP being the very last. The "up" button works just fine. The other buttons are completely non-functional except for the "right" button in the corner that it shares with the "up" button. In these images, the red box is the camera actor.
So I'm confused why it's only the last of the buttons that works. I thought maybe it'd be because so many actors were using the same behavior, but I have all of the little zombie guys running the same behavior and they all walk around with no problem. I had considered making a scene behavior to operate all of this, but it didn't work. I also considered eliminating the middleman with the camera actor, but I couldn't see how to get the camera to move nicely.

Thanks for your time, any help would be appreciated!


  • *
  • Posts: 2545
Okay so your problem here is with the setting the x and y speed of the camera to 0. The "when updated" events trigger in the order of creation for the actors.

Imagine your mouse is over the first actor you created. This sets the x and the y speed to the correct value. However, the next actor comes around and looks and sees the mouse isn't over itselylf so sets the x and the y speed of the camera to 0. I guess one way to fix this would be to only set the x and y speed of the camera to 0 if the mouse isn't over any of the actors


  • Posts: 28
Ah, thanks for spotting that issue--I'll try that out when I get the chance to fix it!