how do i make a missile to follow a specific actor?

guillefaceguilleface Member Posts: 1,014
edited November -1 in Working with GS (Mac)
so basically i want to create a special weapon for my main actor when it shoot i want to spawn like 3 missiles at once, and then if i have 3 enemies i want each of the missile to follow one actor each, i have no problems with spawning the missiles but cant make them to follow a different enemy

Comments

  • guillefaceguilleface Member Posts: 1,014
    sorry i dont mean a specific actor, i have different types of enemies at once on my scene,let say 2x ufo plane,2x jet,2x airplane, i just want for the 3 missiles to destroy one of this actors randomly, each missile one, thanks
  • firemaplegamesfiremaplegames Member Posts: 3,211
    This is extremely difficult to do without a table or an array to hold a list of all the current Actors on the screen.

    This is the same thing you would need to make a homing missile in a tower defense game.

    Having all the enemies shoot missiles at the player is doable, but the other way around is not really feasible currently in GameSalad.
  • svnsvn Member Posts: 445
    Well, maybe this will help: Create two Game Real Attributes. Call them: EnemysX and EnemysY. Now, in each of your enemy actors, create two Constrain Behaviors: constrain "game.EnemysX" to "self.Position.linear.X" and constrain "game.EnemysY" to "self.Position.linear.Y".
    Now, in your missile actor, tell it to Move To "EnemysX"(for X) and "EnemysY" (for Y). Now, the missiles should go toward each enemy- or they will just zoom randomly around- I really don't know. I'm sorry for not being more helpful.
  • old_kipperold_kipper Member Posts: 1,420
    You could do it with an invisible 'first shot', a 'lock on' to identified the enemy actor by aiming at it, and by having your player actor fire an invisible actor that based on your aiming system that sighted the enemy. This then would caused the enemy to start putting it's coordinates into a pair of game or scene attributes so the missile could target it. It would also work as part of a visual system to show the lock on, and might make for some interesting gameplay if you then allowed the enemy to break from the 'lock on' given certain rules.

    hope that helps.

    kipper
  • guillefaceguilleface Member Posts: 1,014
    Thank you guys i really apreciate your time for helping me i will try this methods and see how it goes
  • old_kipperold_kipper Member Posts: 1,420
    you might try using an invisible bar that is constrained to the main actor's position and it's rotation as that would do your lock on for you when the enemy was checking for collision. It would be just a case of choosing a time when it was intersecting and the enemy was live and you wanted to fire.
  • hman360hman360 Member Posts: 590
    If you still can't do it, email your project to redsox360blog@gmail.com and I'll try to do it for you for free.
  • guillefaceguilleface Member Posts: 1,014
    hman i really dont have a project iam working on pictures first and in gamesalad iam working on things i would like to add, i just open a new project and work with square colors lol, i will feel bad sending you something like that, anyways this is what i did, i create 2 enemies, on each i have a gamex costrain to selfposition for x and y,
    so in the missile i have to move to game x and game y, if i have one enemy it works ok, so i add another enemy with same constraning self position x and y, so i thought i could add on the "move to" like this
    ramdom(gamex,gamex2) and ramdom(gamey,gamey2) gamex2 and gamey2 is for the second enemy
    so basically i wanted for the missile to chose between this two options but it moves very weird i guess because is trying to move to both destination at once :(
  • rlehmrlehm Member Posts: 320
    I did this and it worked:

    Make your main actor drop a missile, and have it move forward SLOWLY... like it's getting ready to blast off, building momentum..

    add several invisible actors one below each other down the screen.. have them about 60-70% at the other side.

    |--main actor---------------wall------|

    in each wall piece set up an attribute,
    if collide change attribute wall1 to true

    in your missile

    if wall 1 true
    (add rules to make it fire in wall piece direction)
    attribute fired true

    in all rules,
    if attribute fire false

    what does this do?

    the missle moves forward slowly, and the first actor to cross an invisible block triggers the missile to accelerate quickly toward it's direction... the same location as the enemy :) it then collides and kills the enemy

    if you had time.. you could add these invisible squares all over and it'd work better... but this worked fine for me.

    remember.. add the if fired = false on all the rules in the missile so it ONLY fires at the first one it blows up

    add a

    fired = false to the collision so it resets in case you have another missile floating around :)
  • guillefaceguilleface Member Posts: 1,014
    hi rlehm would you be able to send me that project , i try it but i still dont understand where to create the attributes for which or in game attribute or in the actor attributes
  • jb15jb15 Member Posts: 602
    @ rlehmOr, could you post it online (like on mediafire.com or somewhere) to share it with the whole community? I'm very interested in how you accomplished this.
Sign In or Register to comment.