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
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 :)
<iframe frameborder="0" src="" width="552" height="167"></iframe>
Posts: 254
Reputation: 2,389

Return to How do I....?

Who is online

Users browsing this forum: Abhigamer123, totoe and 1 guest