[SOLVED] Ranged attack question

For questions about using Classic.

Post » Thu Jun 09, 2011 3:08 pm

In my game there are enemies who attack in melee and rangers. Melee opponents work just fine but I've encountered problem with rangers. I'm using Line of Sight behavior for targeting and attacking and Platformer for movement. If there are several rangers near the player instead of all only one of them attacks. What is the reason?
B
54
S
11
G
4
Posts: 250
Reputation: 5,074

Post » Thu Jun 09, 2011 3:19 pm

Can you post a screenshot of that situation? It sounds like they are blocking each others line of sight if they are all solid and your line of sight behaviour says to collide with solids.
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Thu Jun 09, 2011 3:20 pm

Its probably because line of sight doesn't work well with multiple instances.
Since this is platform, and you probably only need a single axis to compare, try the overlapping at offset condition. Like ranger is overlapping at offset enemy 30x 0y.
Then -30x 0y for the left side.
If you do need both axes then you can use distance(x1,y1,x2,y2), but you may need something else to pick.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Thu Jun 09, 2011 9:56 pm

[quote="Jayjay":3g6kmt28]Can you post a screenshot of that situation? It sounds like they are blocking each others line of sight if they are all solid and your line of sight behaviour says to collide with solids.[/quote:3g6kmt28]
They are not solid

The left one is shooting second bullet on this screenshot while the right one isn't shooting at all.
B
54
S
11
G
4
Posts: 250
Reputation: 5,074

Post » Thu Jun 09, 2011 9:58 pm

[quote="newt":3qebrsj9]Its probably because line of sight doesn't work well with multiple instances.
Since this is platform, and you probably only need a single axis to compare, try the overlapping at offset condition. Like ranger is overlapping at offset enemy 30x 0y.
Then -30x 0y for the left side.
If you do need both axes then you can use distance(x1,y1,x2,y2), but you may need something else to pick.[/quote:3qebrsj9]

I tried that but situation is the same :cry:
B
54
S
11
G
4
Posts: 250
Reputation: 5,074

Post » Thu Jun 09, 2011 11:50 pm

I've got it! The problem is in spawn another object event! It seems that only one enemy could be a "bulletspawner" at the same time! Any suggestions how to fix it?
B
54
S
11
G
4
Posts: 250
Reputation: 5,074

Post » Fri Jun 10, 2011 10:06 am

[quote="Wolod":venji16c]I've got it! The problem is in spawn another object event! It seems that only one enemy could be a "bulletspawner" at the same time! Any suggestions how to fix it?[/quote:venji16c]

Create a "For each object" loop and select the shooters. Then put your shooting event inside of that loop. This will make each enemy shoot when they have LOS.
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Fri Jun 10, 2011 12:47 pm

[quote="Jayjay":2l5gt2df][quote="Wolod":2l5gt2df]I've got it! The problem is in spawn another object event! It seems that only one enemy could be a "bulletspawner" at the same time! Any suggestions how to fix it?[/quote:2l5gt2df]

Create a "For each object" loop and select the shooters. Then put your shooting event inside of that loop. This will make each enemy shoot when they have LOS.[/quote:2l5gt2df]

It causes crash! Debugger tells me that it may be bug in Construct...
By the way here is a screenshot with my event
B
54
S
11
G
4
Posts: 250
Reputation: 5,074

Post » Fri Jun 10, 2011 3:55 pm

Hmm, now it looks like a bug with the LOS behaviour. I've had similar problems in my game using LOS :?

Maybe have a variable "HasLOS" for each object, then check if that variable is true. Then, outside of the for loop have the condition "En6box Has LOS to Player" and action "HasLOS = True" and then another condition below "Else" with action "HasLOS = False".
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Fri Jun 10, 2011 5:06 pm

[quote="Jayjay":27njurf5]Hmm, now it looks like a bug with the LOS behaviour. I've had similar problems in my game using LOS :?

Maybe have a variable "HasLOS" for each object, then check if that variable is true. Then, outside of the for loop have the condition "En6box Has LOS to Player" and action "HasLOS = True" and then another condition below "Else" with action "HasLOS = False".[/quote:27njurf5]

Crash anyway :(
B
54
S
11
G
4
Posts: 250
Reputation: 5,074

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests