Distance

Get help using Construct 2

Post » Sun Aug 05, 2012 8:51 pm

Might try overlap at offset.
Image Image
B
161
S
48
G
90
Posts: 7,350
Reputation: 66,755

Post » Sun Aug 05, 2012 8:53 pm

@Mipey Do you see any errors here? because everything works besides when I go above him, he still chases me, when he's supposed to go to patrolling mode... if you're interested, I could also give you the .capx

https://dl.dropbox.com/u/94572684/Pictures/Untitled.png
B
13
S
3
G
1
Posts: 44
Reputation: 1,152

Post » Sun Aug 05, 2012 9:01 pm

@Kid4lynn:
Could be that you only check for Y position in the first first event. When the player is above enemy Y, first event is false, but second is still true.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sun Aug 05, 2012 9:05 pm

@Mipey oh man, can't believe I missed that...

Although that didn't change anything, thanks for pointing that one out.
B
13
S
3
G
1
Posts: 44
Reputation: 1,152

Post » Sun Aug 05, 2012 9:13 pm

I would set it up something like this (+ event, > action, ++ subevent, >> action in subevent, sorry I can't be arsed with formatting, got big enough headache with project of my own :) )

+ Every tick
> Enemy: Set Sight to false (this basically sets all enemies to blind mode...)

+ abs(Player.X - Enemy.X) < 300 (... but right after that, we check for enemies which still see player and set 'em back to true)
+ Player.Y == Enemy.Y (they're on the same platform, as long as player and enemy sprites have the hotspot at same height)

++ Is mirrored
++ Player.X < Enemy.X
>> Enemy: set Sight to true

++ is NOT mirrored
++ Player.X > Enemy.X
>> Enemy: set Sight to true
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sun Aug 05, 2012 9:18 pm

I would suggest you add some room to the Y at which enemy can still see the player, though... Like this:

abs(Player.Y - Enemy.Y) < 20

So when the player gets within 20 pixels of Enemy's Y position, it gets frisky. You can adjust that for height of enemy sprites too, if you want, such as:
abs(Player.Y - Enemy.Y) < Enemy.Height

Depends where you have hotspots, you can adjust at will.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sun Aug 05, 2012 9:23 pm

@Mipey Yeah :c as you can see Game

Its not working well because of how the Y is set up..
B
13
S
3
G
1
Posts: 44
Reputation: 1,152

Post » Sun Aug 05, 2012 9:37 pm

https://dl.dropbox.com/u/629300/construct/projects/stealth_game_sight_solution.capx
It works. The enemy will jump when he spots you, though.

Now I'm off to sleep, hopefully you'll be able to figure it out! Good luck!Mipey2012-08-05 21:39:08
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sun Aug 05, 2012 9:55 pm

@Mipey We need more people like you on this forum, thanks a ton!
B
13
S
3
G
1
Posts: 44
Reputation: 1,152

Post » Sun Aug 05, 2012 10:56 pm

@Mipey that was great what you did. You want to do something more to this example?delgado2012-08-05 22:56:55
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,963

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests