Attack Spesific Instance of Enemies

Get help using Construct 2

Post » Mon Mar 20, 2017 4:00 am

Hello :)

I'm currently creating a game that looks like RPG game. I have an issue to attack specific instance of enemies with a bullet which the bullet always aim the clicked or targeted enemy. In this case I use Set Angle Toward Position in Every Tick Event. There the issue appears. Every X second an enemy will spawn. But, when I click specific object the bullet will aim random enemy. How do I can match the bullet target with clicked enemy? That action is possible in the same event (Click Event), but in another event (That is Every Tick event) the targeted enemy cannot be determined.

I try like this:

On Left Button Click on Enemy -------> Spawn Projectile
Every Tick -------> Projectile Set angle toward (Enemy.X, Enemy.Y)

I heard this can be solved by matching UID. But I don't know. Can you help me?

Best regards
Creating games makes your imagination realized
B
14
S
4
G
1
Posts: 55
Reputation: 1,130

Post » Mon Mar 20, 2017 5:00 pm

Add a variable called 'TargetUID' to the bullet.
On Left button on Enemy: Spawn projectile. Set Bullet.TargetUID to Enemy.UID
Set the angle toward Enemy( Bullet.TargetUID ).X, Enemy( Bullet.TargetUID ).Y

That's it :)
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 247
Reputation: 2,318


Return to How do I....?

Who is online

Users browsing this forum: draiza and 5 guests