How do I Bullet Behavior

Get help using Construct 2

Post » Fri Jun 19, 2015 5:24 pm

How I do I say when (whatever) is created go to the direction of the player.

Im trying to spawn the same enemy on both sides of the enemy that converge on the player. I tried the angle(self.x,self.y,player.x,player.y) and I'm not getting the behavior i want. they end up slanting above the ground or something. Also I don't want the enemies too float off the ground I want them to stay on whatever ground I spawn them on (depending in on the level design of course). I just need them to know. Ok I was spawned, player is X direction, set bullet of motion to X direction. PLEASE HELP ME its such a simple problem that I don't know the answer too and its holding up my hold project.
B
6
S
1
Posts: 46
Reputation: 476

Post » Fri Jun 19, 2015 5:53 pm

You shouldn't use the bullet behavior for that. The bullet behavior just shoots an object in one direction. That's why it floats off the ground.
You need to use the Pathfinding behavior. So you let the enemy find a path (If the player's position is changing then every tick) and then you let the enemy go along the path that it found. It should find the player like that :D
I hope I could help!
Image
B
5
S
3
Posts: 193
Reputation: 1,063

Post » Fri Jun 19, 2015 6:36 pm

Thanks Im going to give it a try
B
6
S
1
Posts: 46
Reputation: 476

Post » Sun Jun 21, 2015 12:11 am

I found a solution to my problem and if anybody needs help with this here is what I did to fix my problem.

The Problem: I wanted my enemies to go in the direction of player at all times. The problem with the bullet behavior is that if I set the angle of motion it effects all the of the spawned enemies of the same name. (if I spawn the samurai and set its angle of motion to 180, all the samurai went at the motion) This isn't converging on the enemy because they are spawn on both sides

Solution: It seems so simple now. What I found out is that if you make an event that with the enemy class you want to target, and you select "is clockwise from" in the angle section. (Focus on making the enemy/sprite you want to go left cause by default the bullet behavior sends a sprite right)

Depending on your game this part might be a little different but, when it asks for an angle input the MAIN CHARACTERS OF YOUR GAME X position. This part distinguishes what enemy you are talking about. (Which enemies are clockwise from player.x? ok them, now what do we do)

lastly you have to make sure your only affecting the enemies on that side by adding a condition. the condition I used compare the X coordinates of the enemies and the player. With construct 2 the X coordinate increases from left to right, AND i want to target the enemies are the right of the player, SO if the enemies X is Greater than the player's X, THEN set the bullet motion angle to 180 degrees.

* only bug i found with this approach is that the enemies that are coming at the enemy from the left, will double back when their X becomes greater than the players X, which kind of looks silly, but if I "Fix" it will yo-yo the other's back also so I'm leaving it and design around it. IF you guys think of a way to fix it then go ahead
B
6
S
1
Posts: 46
Reputation: 476

Post » Sun Jun 21, 2015 12:15 am

You could use the pathfinding behavior but I was scare to personally because I didnt know how much it would take from the performance of the game because i want to port this to mobile. So if you want to get this to work with the pathfinding behavior then go ahead

#EnemiesConvergeOnPlayer #MakingPlayerFocialPointOfEnemies
(I dont know how to tag this in the search for other people looking for a similar solution if you know please do so because this could help someone)
B
6
S
1
Posts: 46
Reputation: 476


Return to How do I....?

Who is online

Users browsing this forum: Laurent and 11 guests