Redirect bullets with sword

Get help using Construct 2

Post » Sun Oct 21, 2012 12:49 am

Hi everybody, I wanna make something similar to SW Lightsabers. I want my character to redirect bullets with a sword to the bullet-source.

I tried something using "Set angle toward (enemy.X, enemy.Y)" when bullet collide with sword, but when there are more enemies at screen, bullet doesn't detect the real enemy source and goes towards another enemy.

Can anyone help me, please? :3HNK2012-10-21 01:23:12
B
5
Posts: 10
Reputation: 595

Post » Sun Oct 21, 2012 12:57 am

Sure! You will need an instance variable on the bullet called "enemyUID" or something. Then, when the enemy shoots the bullet, set this value to enemy.UID.

When reflecting, use the 'pick by unique ID' expression to shoot it back at the correct enemy.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sun Oct 21, 2012 1:42 am

Thanks, that gave me some hint how to do that.   

Unfortunately, I don't know how UID works, I tried this, but it doesn't work:



MCTest and MCShad are player and enemy respectively, and "Is Attacking" is disabled for test matters.
B
5
Posts: 10
Reputation: 595

Post » Sun Oct 21, 2012 1:54 am

You are using 'bullet - pick instance with UID' instead of 'enemy - pick instance with UID'.

Just think of UID as a number that is unique to every instance of every object in the game.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sun Oct 21, 2012 2:22 am

AWESOME! It works very well!

Thanks a lot!
B
5
Posts: 10
Reputation: 595

Post » Sun Oct 21, 2012 3:10 am

No problem, glad I could help :)
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400


Return to How do I....?

Who is online

Users browsing this forum: randomly, Walessio and 24 guests