How do I make an enemy that disappears, then reappears?

Get help using Construct 2

Post » Mon Dec 12, 2016 1:39 am

I want to make an enemy that disappears, and then reappears to attack you, but I don't want you to be able to make contact with him unless he his visible. I've tried to use variables, but I don't think that I'm even close to what I want. I can supply an example of my capx, but it might take some time.
B
24
S
9
Posts: 113
Reputation: 2,012

Post » Mon Dec 12, 2016 2:04 am

Use an instance variable if there are multiple of them. Call it "hidden" and make it a boolean or whatever you want, then do whatever you do to decide when the enemy hides, and make hidden true at the same time.
You can then say:
Code: Select all
if hidden = true
     enemy: set collisions disabled
else
     enemy: set collisions enabled
B
27
S
6
G
5
Posts: 18
Reputation: 3,967

Post » Mon Dec 12, 2016 2:14 am

LoneVox wrote:Use an instance variable if there are multiple of them. Call it "hidden" and make it a boolean or whatever you want, then do whatever you do to decide when the enemy hides, and make hidden true at the same time.
You can then say:
Code: Select all
if hidden = true
     enemy: set collisions disabled
else
     enemy: set collisions enabled


Thanks! I'll give it a try! :D
B
24
S
9
Posts: 113
Reputation: 2,012

Post » Mon Dec 12, 2016 2:24 am

You can use "Is visible", or "Compare opacity", depending on how you make it invisible.
ImageImageImage
B
71
S
22
G
257
Posts: 3,788
Reputation: 142,692

Post » Mon Dec 19, 2016 12:31 am

blackhornet wrote:You can use "Is visible", or "Compare opacity", depending on how you make it invisible.

I'm using different fade behaviours to make him come in and out of view, but when all of the fading is done and everything resets, he is invisible when fading out again. I checked the debugger, and it says that the fade-In behaviour is still in the fade-out stage, even though I set it to zero. Any ideas on how to fix this?
B
24
S
9
Posts: 113
Reputation: 2,012

Post » Mon Dec 19, 2016 1:54 am

I'd have to see an example.
ImageImageImage
B
71
S
22
G
257
Posts: 3,788
Reputation: 142,692

Post » Mon Dec 19, 2016 3:08 am

blackhornet wrote:I'd have to see an example.

Took me a while, but here you go.

https://www.dropbox.com/s/m2witzr2nv9sz ... .capx?dl=0
B
24
S
9
Posts: 113
Reputation: 2,012

Post » Mon Dec 19, 2016 3:46 am

This seems extremely complicated. Can you explain what you want? I get the general idea, but specifically, how should this work?
ImageImageImage
B
71
S
22
G
257
Posts: 3,788
Reputation: 142,692

Post » Mon Dec 19, 2016 3:56 am

blackhornet wrote:This seems extremely complicated. Can you explain what you want? I get the general idea, but specifically, how should this work?


When you get in his line of sight, He fades away, gets right behind you and fades back in and attacks. After that he fades back out, goes back to where he started, then fades back in. The only problem is that once the whole cycle starts again, he stays invisible after he fades out.
B
24
S
9
Posts: 113
Reputation: 2,012

Post » Mon Dec 19, 2016 5:18 am

Aquanex2 wrote:
blackhornet wrote:This seems extremely complicated. Can you explain what you want? I get the general idea, but specifically, how should this work?


When you get in his line of sight, He fades away, gets right behind you and fades back in and attacks. After that he fades back out, goes back to where he started, then fades back in. The only problem is that once the whole cycle starts again, he stays invisible after he fades out.



i didnt opened your capx, but here is my own version of unexpected behavior AI

the AI is by default patrolling, then the last move=4 is what is triggering the unexpected fade out/in and action (whenever the player enters the enemy distance of patrolling by 100 pixels then AI spots him and unexpectedly stabs him in the back.

then if your player wold have something like a bullet shot at it, you wold compare if enemy.move<4 or not equal with 4 then trigger your usual life lose on enemy, else miss.


however the code is getting stuck not sure why, ATM but as a example should do the trick so you can understand how you can use proximity and visual effect with opacity.
B
78
S
23
G
69
Posts: 1,353
Reputation: 44,025

Next

Return to How do I....?

Who is online

Users browsing this forum: katzin, Yahoo [Bot] and 7 guests