(SOLVED)How do I make Line of Sight apply individually

Get help using Construct 2

Post » Mon Aug 10, 2015 9:51 am

Hello.

So I am setting the AI for my platformer enemies. My first type is working just fine (is a pretty simple patrol) but the new type I am working on is causing me some trouble.

So whenever the enemy has on sight the player I have set the range and the cone of view to 90, so is just sees forward. Then I have set some instance variables whenever if he has you on sight, he will shoot you.

Everything works fine expect one thing:

Lets call the enemy: Caster. So if Caster#1 has you on sight, doesn't matter if Caster#2 doesn't have you on sight because you ll see his proyectiles coming at you from somewhere outside the screen because the sight applies to the sprite. How can I overcome this?

Thanks
Last edited by Smileh on Tue Aug 11, 2015 10:07 am, edited 1 time in total.
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Mon Aug 10, 2015 9:58 am

You should add instance variable (boolean) to Caster in order to prenvets your problem
Image Image
B
22
S
13
G
130
Posts: 869
Reputation: 67,816

Post » Mon Aug 10, 2015 10:50 am

MadSpy wrote:You should add instance variable (boolean) to Caster in order to prenvets your problem


Could you elaborate a bit more? I am kind of a begginer.
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Mon Aug 10, 2015 11:37 am

You can try something like that:
add boolean instance variable to object "Caster" (eg "SeePlayer" default false)

Caster has LOS Player AND caster boolean instance variable "SeePlayer" is false (use invert)
---> Caster set boolean "SeePlayer" true

Caster has NOT (use invert) LOS Player AND caster boolean instance variable "SeePlayer" is true
---> Caster set boolean "SeePlayer" true

Pick Caster boolean "SeePlayer" is true
---> Caster action (whatever you want Caster must do)

You could improve this with adding timer for reload time or using functions
Image Image
B
22
S
13
G
130
Posts: 869
Reputation: 67,816

Post » Mon Aug 10, 2015 12:18 pm

I already had something like that set up if true stop walking and start shooting and if false keep the patrol.

My problem is like I said, if I have both casters one of each side, if one spots me, the other one shoots. I kinda need to make them unique or something like that to the sight.
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Mon Aug 10, 2015 12:56 pm

could you share the capx?
Image Image
B
22
S
13
G
130
Posts: 869
Reputation: 67,816

Post » Mon Aug 10, 2015 2:36 pm

Gotta go to work right now. I will try to do when I come home. You can check the platform AI on the store, is the one I have as example to learn.
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Mon Aug 10, 2015 10:24 pm

Ok so here's the capx. Hopefully you can help me.

drive.google.com/file/d/0B69SFeoPTx8kRjhTazBPaGFTamM/view?usp=sharing
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Mon Aug 10, 2015 10:57 pm

on event 20, you set boolean "sight" to all the familie instead of set boolean only for the Caster who has LOS your player
Image Image
B
22
S
13
G
130
Posts: 869
Reputation: 67,816

Post » Tue Aug 11, 2015 9:34 am

That was it, thanks dude. I didn't think that would mess it up. Still not sure when to use families. I did that so I could use it for future enemies but didnt think it will bug it out.
B
14
S
5
Posts: 248
Reputation: 1,705

Next

Return to How do I....?

Who is online

Users browsing this forum: adamebastin, plinkie and 8 guests