Vector towards player. How to?

For questions about using Classic.

Post » Thu Feb 25, 2010 9:08 am

Hi, it's me again. Seems I'm here every 5 minutes with a question :)

I'm making a simple Robotron clone. Doing a lot of these easy projects (?) to get to grips with Construct. Atm I've got the enemy sprites checking their X and Y towards the player sprite X and Y. If it's more, decrease. If it's less, increase. This works OK so the enemy are moving towards the player but it ends up with the enemy sprites all lined up in a row if you move around enough. Hard to explain really but suffice to say it's crap.

So my question is, is there something in Construct that will allow me to vector the enemies towards the player sprite, rather than just inc X and dex Y etc?

Any help appreciated as always.

Ta very glad. :wink:
B
2
G
2
Posts: 12
Reputation: 674

Post » Thu Feb 25, 2010 9:16 am

You can always change their angle towards the player - either right away or in increments.

Or you can use the Custom Movement behavior - it has a "Move toward" event.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Thu Feb 25, 2010 10:34 am

It would help if we knew the method you're using to move your enemies. Perhaps you could post a .cap?
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Feb 27, 2010 2:37 pm

I've managed to work it out.

Before I was just setting the X and Y of the enemies based on the current player position. If the players X was higher than the enemy, increase the enemy X ... etc. It worked but was very rigid and not what I was after.

To fix it, I set the enemies up as bullets. Then set their angle towards the player and BOOM, they all move towards the player in a nice smooth arc. Don't know if this is ideal but it looks and works the best way I've tried.

Thanks for the help :)
B
2
G
2
Posts: 12
Reputation: 674

Post » Mon Mar 01, 2010 4:52 am

As long as it looks and plays nicely for the player.
B
2
G
4
Posts: 13
Reputation: 1,076


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests