Move Window on Start or simulate object coming out of bounds

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hello,

    I have a layout that is the same exact size as the game's window 960x640. However, I am using the pathifinding behavior with my enemies and that is proving problematic with what I want to do.

    What I want to do is simulate enemies appearing into the layout as if they came from outside the screen (left and right). It is similar to the behavior you see in Feeding Frenzy (the game), the fish appear outside of the screen and move into the screen from the left or right side.

    What I have done to try and remedy this is that I spawned my enemies outside of the screen; they have the pathfinding behavior. I gave them a path INSIDE the layout (and therefore the screen) so they move into the screen. However, they never get a path. I later found out a bug report where Ashley said that is by design since the pathfinding assumes anything outside of the layout is infinite and can't be calculated.

    The second method I tried to do is that I made the layout bigger, that way when the enemies spawn outside of the screen they are in the layout still. My problem is, the window is fixed on the top left of the screen and I want it to move to the center of the layout. So the rest can be "extra space" I would use to spawn enemies. I couldn't find any actions or anything on this forum that fixes this problem.

    My other solution is that I would add an action "Scroll to Object" with a "On Start of Layout" condition. However the problem now is that I have to shift everything I have been adding to my layout (which isn't a big deal in of itself). However, with the new setup, I can't get a good visual if for example the GUI text I put is centered when the window scrolls eventually. I have to put the object, play the game and look at it. Didn't find it good enough, move it a bit, then play again and so on and so forth till I fix it. Obviously this is a hassle and a lot of needless fiddling. Is there a way to fix the issue I am having?

    Thank you very much in advance.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • What are the enemies pathing towards? Can you just set it to move towards the thing without using pathfinding? i.e. Set Angle. There's a ghost shooter tutorial level where monsters spawn outside of the layout and move towards the player without the use of pathfinding. If you definitely need pathfinding then have them move towards the central point of the level until they are inside the layout then enable pathfinding?

  • What are the enemies pathing towards? Can you just set it to move towards the thing without using pathfinding? i.e. Set Angle. There's a ghost shooter tutorial level where monsters spawn outside of the layout and move towards the player without the use of pathfinding. If you definitely need pathfinding then have them move towards the central point of the level until they are inside the layout then enable pathfinding?

    They are pathing towards a random point inside the layout. I tried a Move but it isn't working very efficiently, half the sprite must be inside the layout for the pathfinding to kick in (or that is what I think anyway). This eliminates the part where the player would feel the enemies are coming out of the boundaries. I tried to do it like the tutorial where I use the Bullet behavior and rotate the enemy towards a random point inside the layout, then once the enemy is inside the layout (inverting the "Inside Layout" condition) I would disable the Bullet behavior and activate the Pathfinding. Unfortunately, it doesn't work. The bullet gets disabled but the pathfinder still doesn't get a path.

    Worthy of note however that the second method (Bullet + Pathfinding), C2 considers the sprite is inside the layout when at least 2-3 pixels of the sprite are INSIDE the layout. Yet, the pathfinding doesn't get a path (which I believe is because it is still considering the sprite is outside of the layout). I then had a condition testing where X is more than 10 and less than 960 then disable Bullet behavior and activate Pathfinding. The pathfinder gets a path and the "isMoving" boolean is set to true on the enemies but they don't move. They stop. So I am unsure what to do really.

  • Well it sounds like it is working except for the very last bit which could just be a few tweaks with the logic. Does the pathfinding work if the enemies are actually spawned inside the layout with the current logic? i.e. is the pathfinding logic working on its own? Does it work for a single enemy?

  • Yes, the pathfinding works fine if it is inside the layout. However with the current setup, it doesn't. Even with the old setup it worked (With move; once the object is fully inside the layout, it worked). Not sure why with Bullet it doesn't.

  • With the solution of a bigger layout, on start of the layout use the system action "Scroll to position" using the average middle of your layout as destination.

    As for your GUI, place it on its own layer with parallax parameters set to 0,0 and place it according to the "project size rectangle". (https://www.scirra.com/tutorials/37/beginners-guide-to-construct-2/beginners-guide-to-construct-2/page-7)

    On start of layout, your "camera" will automatically scroll to the middle of your layout, providing the necessary space around to spawn enemies, and your GUI will still be appropriate.

  • With the solution of a bigger layout, on start of the layout use the system action "Scroll to position" using the average middle of your layout as destination.

    As for your GUI, place it on its own layer with parallax parameters set to 0,0 and place it according to the "project size rectangle". (https://www.scirra.com/tutorials/37/beginners-guide-to-construct-2/beginners-guide-to-construct-2/page-7)

    On start of layout, your "camera" will automatically scroll to the middle of your layout, providing the necessary space around to spawn enemies, and your GUI will still be appropriate.

    That actually gave me an idea. What I did to resolve this situation is that I created a sprite with size set to the window size. Placed it on a layer of its own and called it Guide and locked the layer. Next I set the Background layer I had to transparent and did what you mentioned with the GUI's layer being set to 0, 0 in Parallax.

    With this I resolved my primary problem of having some kind of guide when creating the levels so I don't have to guess where to put objects. Also that GUI tip escaped me so that resolved the issue as well with GUI being on different locations. Thank you very much!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)