How can do multiple targets follow?

szzg007

  • Posts: 65
How can get actor name in scenes? --- I use 3.3
I want to make games aircraft, the aircraft can launch missiles. Tracking enemy missiles.
What should I do? Acquire all kinds of enemies?
If anyone can give me to teach? Tutorial or guide me where? Example?

thanks

« Last Edit: March 30, 2015, 12:59:19 am by szzg007 »

PhilIrby

  • Posts: 545
code designer screen -->Palette  -->scene-->actor
for each actor on screen
for each actor inside region
for each actor of type
for each actor of Group

Use  these to select  Target (actor attribute) and the use Follow Target behavior.

szzg007

  • Posts: 65
thanks....I has use each, but , always be the last...


szzg007

  • Posts: 65
How can rename actor? user Command
(not in tools)

« Last Edit: March 28, 2015, 09:25:16 am by szzg007 »

PhilIrby

  • Posts: 545
You don't rename, you set it to an actor attribute which allows access to any other behavior in your scene.
See attached image .  Doesn't need to be in a custom event like the image. If you need to target more than one at a time , it might get  complicated and it would take me a little more time to figure out.   I you need to select only a certain ones of the actor type or group, you could assign  one or more actor values to them right after they are created. Then you could set up logic inside the For Each Actor Type to pinpoint those special ones.

« Last Edit: March 28, 2015, 10:21:46 am by PhilIrby »

PhilIrby

  • Posts: 545
Here is a useful behavior which will identify the nearest enemy and also shoot at that enemy.  You would be avoiding his problem by using  actor of type or member of group.
  http://community.stencyl.com/index.php/topic,40025.0/topicseen.html

szzg007

  • Posts: 65
@PhilIrby
thanks...I trying now...
Yes. Maybe I think into a complex situation. You're probably right.
Glad you could teach me.
Thanks a lot.
//===============================
Still have the same problem.
I also fired more missiles.
Only the last missile can always find the target.
<a href="http://www.szzg007.com/Flashgames/2dAircraftgame.swf" target="_blank" class="new_win">http://www.szzg007.com/Flashgames/2dAircraftgame.swf</a>

« Last Edit: March 28, 2015, 08:42:32 pm by szzg007 »

szzg007

  • Posts: 65
How can do multiple targets follow

PhilIrby

  • Posts: 545
Sorry, I haven't been able to work on this much.  I have a simple missile behavior completed but its not how I want it yet.  Give it a try.  Mouse click creates a new missile (You seem to have that already set up),  each new missile will acquire a target and fire. if you create them  too  fast it will not acquire a target but it will fire in the direction as the previous shot. You need to play with it a while to get a feel for how fast to create a missile.  I'll still work on improving the behavior and post what ever I come I come up with.

« Last Edit: March 30, 2015, 06:55:25 pm by PhilIrby »

szzg007

  • Posts: 65
I have also created a 3 missile. However, only the last one can find the target. At the same time. The missile can only have a goal. When the target dies. He moved to the scene at the bottom right. This is very strange. Not? The following is my project. You can see it. All the work on Fire Multiple Bullets.
OK. I can send u ..Please get me u mail.thanks

« Last Edit: March 30, 2015, 07:19:55 pm by szzg007 »

PhilIrby

  • Posts: 545
Hey szzg007, you have probably already solved your problem or given up by now .  But just in case you still need  help, I'm attaching photos of a missile behavior that will acquire a target based on closest enemy and then track and strike the target. My missile spawning behavior is a scene behavior.  It will first get a count of enemies in the scene and then spawn as many missiles as there are enemies.

 I did test up to 10 moving enemies and it did work reasonably well.  A spawn rate of every .55 seconds  and a missile speed of 50-55 produced the best results for me, but you are to able change these to suit yourself. It's not perfect, about 40%to 50% of the time with 10 targets it will have one miss, and maybe10% of the time it will have 2 misses.  Misses are not a real problem since you just have to mouse click again to spawn the additional missiles to take out the missed enemies. Let me know if you have questions.

PhilIrby

  • Posts: 545
I've made a significant improvement in the missile behavior which allows you to set the spawning speed to .1 seconds if you want and missile speed  any where from 35 to 50+ with no misses.  Misses were occurring because  more than one missile was selecting the same target. To fix this  you include a [set actor value(target) to (no) for Self] in the creating event of the enemy. Then the missile can check the value of this actor value before it selects a Target Actor.  A revised behavior image is attached.