Enemy following specific route - smooth movement

Get help using Construct 2

Post » Fri Feb 24, 2012 11:48 am

Hi all

At the moment I am messing around with a tower defense-like game. I have an 'Enemy' sprite which should follow a specific path through the layout.

The solution I came up with this far is creating some invisible 'Pointer' sprites and on collision (between Enemy and Pointer) setting the angle of the Enemy equal to that of the Pointer. This allows the enemy to guide through the layout (using the Bullet behavior). However, this does not result in a smooth movement at all, and doesn't look good when the game is played.

Does anyone have an idea how I can make the Enemy sprite follow a specific path through the layout in a "smooth" movement?

Thanks!
B
5
Posts: 12
Reputation: 774

Post » Fri Feb 24, 2012 11:53 am

I recently had to make a tower defense game in a two-week period for a class of mine, and that's the exact method I used. It worked fine for me... If you post your capx file, I can take a look at it and see if we did something differently.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Fri Feb 24, 2012 12:45 pm

Sure, here's an example

EnemyMovement.capx

B
5
Posts: 12
Reputation: 774

Post » Fri Feb 24, 2012 12:47 pm

Did you do anything to make their movement look more smooth? Other than just adding a lot of pointers?

Thanks for your response!
B
5
Posts: 12
Reputation: 774

Post » Fri Feb 24, 2012 1:11 pm

What I did was actually... much less involving than that! Rather than rotate them the way you're trying to, in my game I just made them snap instantly to the new angle. It wasn't pretty, but with such a short deadline, "pretty" wasn't my focus.

Anyway! I found a pretty simple solution for you. Rather than use individual pointers to guide the enemy along the turn, we can use the "rotate __ degrees" actions to take care of all that for us. It took a wee bit of tweaking to get the pointers at the proper places, but it seems to be working just fine!

http://db.tt/G1cwwylb
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Fri Feb 24, 2012 1:28 pm

Hehe, yea, I thought there would be a more simple method for something like this. Your example seems to work fine for what I want to create

I'll move on with something like that, thanks a lot for your help!
B
5
Posts: 12
Reputation: 774

Post » Fri Feb 24, 2012 1:34 pm

No problem! By the way, do you want the enemies to spin on their heads the way they currently do? There's a simple way around that if you'd rather they stay rightside-up.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Fri Feb 24, 2012 2:16 pm

I'll probably be using a different animation later on. Something viewed from above, so it won't matter.

Still curious tho ;) Thinking of the flip/unflip action?
B
5
Posts: 12
Reputation: 774

Post » Fri Feb 24, 2012 2:19 pm

Haha, not quite.

What we were doing before is changing the whole angle, when you also have the option of only changing the angle of motion, which won't affect the sprite's orientation.

http://dl.dropbox.com/u/19702035/EnemyMovement5.capx

Here's the way to do it if you don't want the actual sprite to rotate at all. But if you're using a top-down perspective, I guess the original way is better!
B
20
S
9
G
6
Posts: 607
Reputation: 6,112


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests