Redirect bullets with sword

0 favourites
  • 6 posts
From the Asset Store
The Stickman Sword is suitable for platformer / sidescrolling games
  • 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? :3

  • 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.

  • Thanks, that gave me some hint how to do that.   <img src="smileys/smiley14.gif" border="0" align="middle" />

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

    <img src="http://i.imgur.com/CsrEA.jpg" border="0" />

    MCTest and MCShad are player and enemy respectively, and "Is Attacking" is disabled for test matters.

  • 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.

  • AWESOME! It works very well!

    Thanks a lot!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • No problem, glad I could help :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)