How do I Opponent movement in platform game

Get help using Construct 2

Post » Sun Mar 23, 2014 2:53 pm

Hello. I'm creating a platform game. How do opponents of reaching towards a hero? Sorry, my english is bad.
B
4
S
1
Posts: 14
Reputation: 719

Post » Sun Mar 23, 2014 2:56 pm

there are many ways.one good advice would be to read the "basic platformer tutorial" from ashley.
when you start to get the basics then you can use that knowledge to start adding custom movement or line of sight to make the enemy "smarter"
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Sun Mar 23, 2014 3:37 pm

I know the basics of platform movement. I would like to create an event in which the opponent moves towards the player.
B
4
S
1
Posts: 14
Reputation: 719

Post » Sun Mar 23, 2014 3:54 pm

if playersprite.x<enemysprite.x then simulate key press left on enemysprite(he must have platform behavior and default controls off)
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Sun Mar 23, 2014 3:58 pm

and if you want to attack within a certain range
system compare 2 values
abs(distance(player.x,enemy.x,o,o))
is smaller than 400(this is pixels)
sorry my bad.forgot something.
then make subevent player.x <enemy.x simulate enemy left
and
player.x>enemy.x simulate enemy right
Last edited by Roccinio on Sun Mar 23, 2014 4:03 pm, edited 3 times in total.
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Sun Mar 23, 2014 3:59 pm

and if you have many instances of enemy's dont forget to add above the comparison a 'for each' enemy and then make the rest subevent.system conditions dont pick
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Sun Mar 23, 2014 4:16 pm

Thanks :]
B
4
S
1
Posts: 14
Reputation: 719

Post » Sun Mar 23, 2014 5:23 pm

always happy to help citizens in need. it makes me feel like a superhero :p
B
15
S
6
G
4
Posts: 277
Reputation: 3,948


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 53 guests