Move Window on Start or simulate object coming out of bounds

Get help using Construct 2

Post » Tue Aug 09, 2016 9:11 pm

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.
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Tue Aug 09, 2016 9:42 pm

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?
B
46
S
16
G
79
Posts: 2,170
Reputation: 46,857

Post » Wed Aug 10, 2016 6:43 am

plinkie wrote: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.
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Wed Aug 10, 2016 8:14 am

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?
B
46
S
16
G
79
Posts: 2,170
Reputation: 46,857

Post » Wed Aug 10, 2016 8:27 am

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.
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Wed Aug 10, 2016 9:09 am

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.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
292
S
115
G
96
Posts: 7,295
Reputation: 70,795

Post » Wed Aug 10, 2016 9:50 am

Kyatric wrote: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!
B
19
S
7
Posts: 161
Reputation: 1,751


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, dop2000, oosyrag and 45 guests

cron