# A problem of solids.

Get help using Construct 2

### » Wed May 09, 2012 9:45 pm

Hi, I have a player solid object, and some solid enemies objects.

These enemies, whenever I am close to them, they start start to chase me.

The thing is that if I quiet (don't move), they eventually come to me, and PUSH me.

Is there any way to make them not to push me?
B
6
S
1
Posts: 54
Reputation: 958

### » Thu May 10, 2012 3:42 am

Because both your player and enemy have solid behavior, so it's a reason when enemy come and push your player.
B
50
S
12
G
7
Posts: 259
Reputation: 10,371

### » Thu May 10, 2012 8:45 am

There is probably a lot of different methods, heres two I use though.

First you use an invisible sprite that is bigger than your player sprite and then set its position to your player. Then you give your enemies commands that once they are "overlapping" the sprite that their speed will be reduced to 0, stopping them.

Another way is with the distance checks. For example your condition could be; Distance(player.x, player.y, monster.x, monster.y < your desired distance you want them to stop. And then the action could be again to set the speed to 0.

Just remember if you want them to start running again once you move away - then you need to tell them what to do as well. IE, invert the condition and set the speed to their regular speed again.GenkiGenga2012-05-10 08:48:47
B
81
S
18
G
6
Posts: 1,048
Reputation: 10,908

### » Thu May 10, 2012 11:38 am

[QUOTE=GenkiGenga] There is probably a lot of different methods, heres two I use though.

First you use an invisible sprite that is bigger than your player sprite and then set its position to your player. Then you give your enemies commands that once they are "overlapping" the sprite that their speed will be reduced to 0, stopping them.

Another way is with the distance checks. For example your condition could be; Distance(player.x, player.y, monster.x, monster.y < your desired distance you want them to stop. And then the action could be again to set the speed to 0.

Just remember if you want them to start running again once you move away - then you need to tell them what to do as well. IE, invert the condition and set the speed to their regular speed again.[/QUOTE]

Thanks a lot,
I'm going to give it a try.

Indeed I was trying to do it comparing distances, but I guess I had it done wrong.
B
6
S
1
Posts: 54
Reputation: 958

### » Thu May 10, 2012 1:49 pm

Okay, I'm having a problem.

I've been doing the chasing system this way:
if (player.x - spearman.x) > 0 --> spearman.x += 1; set mirrored.
if (player.x - spearman.x) <= 0 --> spearman.x -= 1; set not mirrored.

Same thing done with Y coord, as I'm doing an isometric game.
This way, it compared positions, and the enemy sprite turns accordingly towards my character.

Of course, doing the "set speed 0" thing won't work, as the enemy will still be moving by coordinates.

I guess I have to do something like this:
if (player.x - spearman.x) && (Distance(player.x,player.y,spearman.x, spearman.y) >= 30) > 0 --> spearman.x += 1; set mirrored.

This way, it will only come to me when it's further than 30px from me, I guess.

However, I can't manage to get the syntax correctly. >.<

EDIT: Nevermind. Think I got it working :DMiyavi2012-05-10 14:03:55
B
6
S
1
Posts: 54
Reputation: 958