User Tag List

Results 1 to 7 of 7

Thread: What is the best way to have ai fire at a random target?

  1. #1
    Clicker Fusion 2.5 (Steam)
    FalconsoftIndustries's Avatar
    Join Date
    Aug 2017
    Location
    Mandurah Western Australia
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post What is the best way to have ai fire at a random target?

    I need my ai to launch a object at a random target only at targets that still exist in the frame in my battle system, for example I have 7 player objects that each have their own attacks and can attack the enemies but I also have 7 enemy objects that each have their own attacks and the battle is over when either the player or computer is defeated. Help.

    Hmmm... I suppose if I use 7 variables and base the target on their random value.
    It might just be possible

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,321
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    You can use ForEach loops to loop through each enemy ship, and then run a new ForEach loop that loops through all potential targets, checks if they have allready been targeted, or else mark them as targeted and add their id to the enemy ship. After the loops ends, all your enemy ships should know which playership to aim at.

  3. #3
    Clicker Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2015
    Location
    Australia
    Posts
    98
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    The easiest way I can think of is by using qualifiers. If all the player objects get given the same qualifier you can test their X/Y positions to make sure they're within the camera's edges, and pick one based off of that


  4. #4
    Clicker Fusion 2.5 (Steam)
    FalconsoftIndustries's Avatar
    Join Date
    Aug 2017
    Location
    Mandurah Western Australia
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks that should work well I will give that a try and let you know how it turns out.
    I just need to pick one from group good, because I don’t use cameras, but can you give me a YouTube video of how you do this “pick one of group good” thing? Because I don’t understand it or how to do that.

  5. #5
    Clicker Fusion 2.5 (Steam)
    FalconsoftIndustries's Avatar
    Join Date
    Aug 2017
    Location
    Mandurah Western Australia
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @marbenx could you please send me a YouTube video of how to do that?

  6. #6
    Clicker Fusion 2.5 (Steam)
    FalconsoftIndustries's Avatar
    Join Date
    Aug 2017
    Location
    Mandurah Western Australia
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah what the hey I will do it using a random variable.

  7. #7
    Clicker Fusion 2.5Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    zip2kx's Avatar
    Join Date
    Jun 2015
    Posts
    732
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    A common way to do it is to set a value in the AI to the fixed value of the target and make it shoot towards that by checking for match.

    Something like this:

    Every 1 seconds
    Target object alt value HP greater than 0 (or whatever else trigger you want to use)
    Pick object Target at random
    ->Set alt value A of AI to Fixed Value of Target

    AI Alt value A is equal to Fixed Value of Target
    ->Fire bullet towards Target
    ->set Alt Value A of AI to 0


    In theory that should every 1 second check for all Target object that has HP greater than 0, then pick one at random, set an value in your AI object to the fixed value id of picked object. Then it checks if the AI value is equal to a Target object and then fire a bullet towards the picked object.

Similar Threads

  1. Replies: 2
    Last Post: 31st March 2017, 06:09 AM
  2. X += (target - X) * .1
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 25
    Last Post: 10th June 2012, 12:54 PM
  3. Touch Joystick, Fire 1 Button, Fire 2 Button
    By ProdigyX in forum Android Export Module Version 2.0
    Replies: 0
    Last Post: 13th February 2012, 02:37 AM
  4. Problem with fire 1 and fire button 2 in beta 11
    By Koji_Kabuto in forum iOS Export Module Version 2.0
    Replies: 1
    Last Post: 31st January 2011, 08:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •