How can tracking missile choose which plane to track ? There are many planes at the same time

In my game, I control a plane to fight with many planes. And I can launch tracking missile.
I have succeeded to let missile track only one plane. But there is many planes at the same time.
I am trying to make a table recording all the plane's position.Then,I find it's very difficult to let missile choose which plane is target. And after same plane been shot down, it's difficult to renew all the index of the left plane in the table .
Is there any demo for me to learn how to make a tracking missile ? I really want to learn some skills.

Comments

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276

    You could use the magnitude function to detect witch plane is closest to the missile.

    Mental Donkey Games
    Website - Facebook - Twitter

  • vectorstudiovectorstudio Member Posts: 50

    Yes,it's a good method. And I know how to detect if a plane is in the shooting angle.
    But I am tired of the logic of the plane table. I have not found a good way to seach in the table.

    @NipaDidIt said:
    You could use the magnitude function to detect witch plane is closest to the missile.

  • FrantoFranto Member Posts: 779

    What you could do, is make an integer, say equaling the total number of planes on screen, for example, 10 planes is the maximum.

    Then on a table or as game attributes, make an x,y for each plane on screen.

    THEN use "accelerate to" or "move to" for the x,y of the plane. The MISSILE would have to have 10 different rules, each rule the same, but with "EnemyX, Y" of that plane number. "If integer is 1, then move to "Enemy1X, Enemy1Y", "If integer is 2, then move to Enemy2X, Enemy2Y," and so on.

    To assign the integer, just use touch to select a plane on screen and the system will register their integer and coordinates. "If actor with integer 2 is touched, then integer = 2"

    Integer 0 could be no plane selected. The missile would either not fire or could fire as a dud for humorous purposes.

    This method would mean a single missile would be able to change targets in route, theres another way, just as covulated, if you want missiles to stick to different targets.

    I only knew to answer to this, because I have a lot of homing attacks in my game.

    Since I'm not so clever, my method is very covulated, the others on the forums can probably do all that with a single expression or rule. I tend to use long but simple methods like this in my game when I can't find the answer to something on the forums.

  • vectorstudiovectorstudio Member Posts: 50

    Thank you very much!!
    Using touch behavior to select target is a good idear.
    In this way, there is no need to use vectortoangle and magnitude to see if the plane is in the range and shooting angle. That's great.

    @Franto said:
    What you could do, is make an integer, say equaling the total number of planes on screen, for example, 10 planes is the maximum.

    Then on a table or as game attributes, make an x,y for each plane on screen.

    THEN use "accelerate to" or "move to" for the x,y of the plane. The MISSILE would have to have 10 different rules, each rule the same, but with "EnemyX, Y" of that plane number. "If integer is 1, then move to "Enemy1X, Enemy1Y", "If integer is 2, then move to Enemy2X, Enemy2Y," and so on.

    To assign the integer, just use touch to select a plane on screen and the system will register their integer and coordinates. "If actor with integer 2 is touched, then integer = 2"

    Integer 0 could be no plane selected. The missile would either not fire or could fire as a dud for humorous purposes.

    This method would mean a single missile would be able to change targets in route, theres another way, just as covulated, if you want missiles to stick to different targets.

    I only knew to answer to this, because I have a lot of homing attacks in my game.

    Since I'm not so clever, my method is very covulated, the others on the forums can probably do all that with a single expression or rule. I tend to use long but simple methods like this in my game when I can't find the answer to something on the forums.

  • UtopianGamesUtopianGames Member Posts: 5,692
    edited May 2015

    @vectorstudio I made a free demo a while back that tracks positions and it picks the closest enemy to your ship.

    Link below if you want to check it out.

    http://www.deepblueapps.com/homing-missiles-template/

  • FrantoFranto Member Posts: 779
    edited May 2015

    @vectorstudio You're welcome!

    @DeepblueApps Awesome demo.

  • vectorstudiovectorstudio Member Posts: 50

    Thank you very much.
    It's a good demo to learn skills

    @DeepBlueApps said:
    vectorstudio I made a free demo a while back that tracks positions and it picks the closest enemy to your ship.

    Link below if you want to check it out.

    http://www.deepblueapps.com/homing-missiles-template/

Sign In or Register to comment.