[Solved] Shoot off limbs + make them fly in right direction

Just started using Construct 2? Post your questions here

Post » Sun Jul 05, 2015 1:52 am

Heyho,

I am making a top down shooter, kind of. I made a simple enemy puppet that is chasing the player. It has got a body, a head and 2 arms. The arms and head are pinned to the body. Now when the player shoots at the enemy and a bullet hits one of the arms, I already get it to

a) not be pinned anymore to the body
b) fly away from the body pretty fast and decelerate until it stops using the bullet behavior

But right now the arms are flying straight forward, like if the enemy is launching them like rockets. In order to make this look good the arms actually have to fly a way in the opposite direction from where the player is standing and shooting. Do you have any idea how exactly the code could look like to achieve the effect?

Thank you!
Last edited by mmoerders on Sun Jul 05, 2015 3:19 pm, edited 1 time in total.
B
3
Posts: 3
Reputation: 181

Post » Sun Jul 05, 2015 10:43 am

Maybe if you make the speed value negative or something like that? :o
B
8
S
1
Posts: 16
Reputation: 602

Post » Sun Jul 05, 2015 2:46 pm

Setting it to negative doesn't work. Remember, we have a top down view, so basically a coordinate system with a X and Y position for the player and a X and Y position for the enemy.

I also tried to get the angle with this method "angle(X1, Y1, X2, Y2)". I set up a global value called AnglePlayerEnemy and set this every 0.1 sec to "angle(player.x, player.y, enemy.x, enemy.y) and when the a bullet hits the enemy's arm I tell the arm to set the bullet angle of motion to the AnglePlayerEnemy value ... but it doesn't work.


edit:

Alright, the closest I got so far to a somewhat accurate outcome is to tell the enemy's arm to "Set angle toward ((player.x),(player.y))". So at least we get the right angle between the player and the enemy. Only thing the arms are now firing straight at the player when they should go in the opposite direction. Now we just need to invert this value somehow. I tried some variations of adding a "-" or a "-1* whateverthepositioniscalled", but nothing works properly ... any suggestions?

edit2:

solved.

EnemyArm set angle to angle(player.x,player.y,enemyarm.x,enemyarm.y)

:)
B
3
Posts: 3
Reputation: 181

Post » Sun Jul 05, 2015 3:56 pm

Didnt know that :o
Thanks for sharing and congratulations for finding out! :)
B
8
S
1
Posts: 16
Reputation: 602


Return to Beginner's Questions

Who is online

Users browsing this forum: brunopalermo and 1 guest