How do I Create clever Enemy

Get help using Construct 2

Post » Tue Feb 10, 2015 11:45 pm

Hi, when enemy see me , i want him to come to my hero and start shoting, but between me and enemy is a gap in the floor. How can the enemy detect there is a gap and jump over it?
B
11
S
3
G
1
Posts: 418
Reputation: 1,780

Post » Wed Feb 11, 2015 6:32 am

Use the line of sight behavior and set it to have custom collision detection and make the pit in the floor one of the objects it can't "see" through.
B
42
S
12
G
1
Posts: 229
Reputation: 3,821

Post » Wed Feb 11, 2015 9:11 am

The solution I saw in a tutorial was to give them a 'detector' sprite, pinned to the forward bottom corner of the sprite, and if it sees open space? Jump.

Here's a little demo game I put together: Control are the arrow keys for left, right, and jump; your score goes up every time you hit the switch, and down every time the enemy collides with you.
You do not have the required permissions to view the files attached to this post.
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Wed Feb 11, 2015 9:17 am

Unnatural20 Not good enough because if you lure the enemy in that gap he cannot chase player. Enemy is stuck and cannot chase anymore
B
238
S
34
G
14
Posts: 1,915
Reputation: 39,026

Post » Wed Feb 11, 2015 10:11 am

Lordshiva1948 wrote:Unnatural20 Not good enough because if you lure the enemy in that gap he cannot chase player. Enemy is stuck and cannot chase anymore


Excuse me? What do you mean, "not good enough"? This is a minigame I put together in five minutes to illustrate "jumping over a gap," not "Here is your game for you."
B
11
S
4
Posts: 152
Reputation: 1,236

Post » Wed Feb 11, 2015 10:14 am

Unnatural20 do not be angry I do apologies if I said something wrong but all I said was if the enemy drops in that place enemy cannot follow player.
B
238
S
34
G
14
Posts: 1,915
Reputation: 39,026

Post » Wed Feb 11, 2015 10:24 am

thank you very much :-))
B
11
S
3
G
1
Posts: 418
Reputation: 1,780

Post » Wed Feb 11, 2015 10:26 am

One possibility to prevent the enemy from jumping, when it can't jump far enough to make it over the gap, you can add two more detector objects, placed even farther out.

After-gap solid detector
This detector confirms that there's a near-enough solid object on the other side of the gap, that the enemy could get to it by jumping.
Notice, though, that this will detect a flat landing spot as a solid, but it will also detect a vertical wall the same way, so it's not good enough by itself. (Unless you don't mind the occasional mid air face-plant into a wall) :)

Clear jump path detector
This detector confirms that there's open air above the landing spot, and open air in the jump arc the enemy would take to get there.
This helps the enemy distinguish between a true landing spot, and a vertical wall. It also prevents them from jumping if the ceiling is too low to make the jump.
B
26
S
17
G
8
Posts: 322
Reputation: 6,017

Post » Wed Feb 11, 2015 12:29 pm

i guess there is not easier way , thank you guys,
B
11
S
3
G
1
Posts: 418
Reputation: 1,780

Post » Wed Feb 11, 2015 1:57 pm

Depending on the complexity of the detection you want to do, instead of using dedicated detector objects, you could try using the "Is overlapping at offset" condition. It will temporarily move your object to an offset from it's current position and test to see if it's overlapping something there, then move the object back to it's original position before any other events run.
B
26
S
17
G
8
Posts: 322
Reputation: 6,017

Next

Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], Fib, imhotep22, raulcg1981, shukra and 1 guest