Pathfinding for ships

Get help using Construct 2

Post » Thu Aug 20, 2015 3:40 pm

Hi guys,

Apologies as i have another question regarding pathfinding or flightpath for ships.

I'm creating a SHMUP and so far from my experience the hardest part for me in developing this game is bullet patterns and flight patterns.

Right now i'm trying to create flightpaths for my enemies and i have been trying and reading some of the other behaviors in which is in this forum.

I have currently added in the events from @R0J0hound pathfinding capx and am really happy with this cause the event made my sprites movement looks realistic as in the gif below.

Image

But i encountered 3 problems:

1) I noticed that with the "flight points" added in as indicated with the light green boxes i can't really "tell" my sprites to actually fly from point A to B then to C, they seemed to fly around to random points .

2) The event will grab all sprites which are in the event sheet itself regardless if they are in the game area or not, how do i have the sprites to fly around when only in the game area?

3) I tried to set "System > Create Sprite > On "Game" Layer so that after creation, the sprite will start pathfinding and moving from point to point but it doesn't work, the sprite just spawns and stays there not moving.

Below is my event list:

Image

I toggled off the spawning cause it doesn't work.

Basically what i want to do is "Spawn Enemies" > Fly (Pathfinding) > Point A to B
B
11
S
2
Posts: 61
Reputation: 704

Post » Thu Aug 20, 2015 3:42 pm

Message: HuaHero can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
This is the said thread for the pathfinding

follow-path-behavior_p558309?#p558309
B
11
S
2
Posts: 61
Reputation: 704

Post » Thu Aug 20, 2015 6:42 pm

I haven't looked at the file but its probably using the objects IID as the order of waypoints.

I think R0J0hound already answered this question in that thread.

Yes, that is possible, but instead of using the IID to access the points store all the points in an array.

Then do these changes to the expressions:
p(n).x -> Array.At(n % Array.Width, 0)
p(n).y -> Array.At(n % Array.Width, 1)
p(n+1).x -> Array.At((n+1) % Array.Width, 0)
p(n+1).y -> Array.At((n+1) % Array.Width, 1)
p(n-1).x -> Array.At((n-1) % Array.Width, 0)
p(n-1).y -> Array.At((n-1) % Array.Width, 1)

B
43
S
23
G
20
Posts: 735
Reputation: 12,027

Post » Fri Aug 21, 2015 2:26 am

@Ethan thanks for your reply!

I can't do arrays at the moment as my version right now is currently free. My target is to at least finish up the 1st level of my game before i make the purchase.

If i were to not use R0J0hound's events and use the custom moving events instead, my sprites will end up moving in a very rigid fashion, is there anyway?
B
11
S
2
Posts: 61
Reputation: 704

Post » Fri Aug 21, 2015 4:50 am

I'm pretty sure you can use arrays in the free version
B
9
S
2
Posts: 54
Reputation: 638

Post » Fri Aug 21, 2015 5:30 am

@MythStylz

Yes i tried and it can be used, my bad i think i mixed it up with families.

I don't really know how to add those into arrays thou. Is there another way for pathfinding but with the fluid movement from R0J0hound's events?
B
11
S
2
Posts: 61
Reputation: 704

Post » Fri Aug 21, 2015 1:41 pm

Sorry all, gonna bump this. Currently at a loss right now

Been reading all day in the forums, have tried litetween, pathfinder, custom movement, bullet, moveto behavior by rex. I cant get any of them to work.
B
11
S
2
Posts: 61
Reputation: 704

Post » Fri Aug 21, 2015 4:47 pm

SO I haven't done it but here's the tips I got:

1) I noticed that with the "flight points" added in as indicated with the light green boxes i can't really "tell" my sprites to actually fly from point A to B then to C, they seemed to fly around to random points .
They seem to be flying in a circle in the gif, as mentioned earlier the IID (Instance ID) is being used, so that the first one created on the screen will be A, B, C etc... If you want more control over that arrays are really simple... Put the position of your green spots (click on them and look in the properties bar) into the array, your Array is gonna be as wide as the number of points you have minus 1, (because it starts at 0), Height is 2 for each coordinate and 1 for depth (which you won't use)

So Points x 2 x 1 will give you a table that looks like:
(Point 1 X, Point 1 Y)
(Point 2 X, Point 2 Y)
ETC...

Now to insert the points into the array is a little code: add action : Array: Insert (Point 1 X) at 0 on X axis, Insert (Point 1 Y) at 0 on Y axis, Insert (Point 2 X) at 1 on X axis, Insert (Point 2 Y) at 1 on Y axis

That should solve that with combined previous stuff ^^

2) The event will grab all sprites which are in the event sheet itself regardless if they are in the game area or not, how do i have the sprites to fly around when only in the game area?

Your gonna want to give the sprites a instance variable (preferably a Boolean: something simple like "active") When it's on the code uses it, when it's off it isn't affected by code. Then your going to have to have some event Trigger to make them active. you could also start the game having a few active and a few inactive, and when you kill one a new one becomes active. But yeah just add the condition that when boolean is on it uses that code.

3) I tried to set "System > Create Sprite > On "Game" Layer so that after creation, the sprite will start pathfinding and moving from point to point but it doesn't work, the sprite just spawns and stays there not moving.

So it's only running the code in order from top to bottom: I.e. it grads all the current Enemy4, then if you create a new one it won't grab that. You can add the actions to the Enemy4 after you spawn it, so after this creating sprite action you have, just repeat... ( this may mess with your previous ships, I haven't tried I don't know, if it does make a t2 and a n2 global variable and get 2 going on.)

What you can also do is add a system>for each step to the for each enemy4 condition (this is also where you should add the boolean condition.) It may work, or it may just constantly set the t and n to the same thing... IDK, try it out. Come back if neither of these work to your suggestion: put what you've done and hopefully somebody smarter than me will awnser
B
9
S
2
Posts: 54
Reputation: 638

Post » Fri Aug 21, 2015 4:56 pm

Wait a second, instead of the Insert command, use the Set at X and Set at x,y commands their a little easier to grasp when your first doing arrays.
B
9
S
2
Posts: 54
Reputation: 638

Post » Fri Aug 21, 2015 7:02 pm

might help, or at least give you another idea.

https://db.tt/lMIxlRMH

edit (9am sat) - I've just had an epiphany - "I'll be back !"

edit my special offer from dropbox has come to an end - I will need to reorganise my links and repost when I get organised
Last edited by RamPackWobble on Sun Aug 23, 2015 6:21 am, edited 1 time in total.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,832

Next

Return to How do I....?

Who is online

Users browsing this forum: Bootfit, OBLIVION and 20 guests