playMaker

Author Topic: Need help for Simple enemy aircraft Ai  (Read 2823 times)

ricard2798

  • Playmaker Newbie
  • *
  • Posts: 13
Need help for Simple enemy aircraft Ai
« on: April 22, 2015, 02:32:31 PM »
So my state machine works on this state.  there is an enemy craft, it has an I tween move update to  a vector 3 global variable for the players aircraft.  it also has another state machine that detects a bullet, destroys itself and creates a copy of itself out of a prefab dulicate (enemy craft) on one of 3 random spawn points.  That all works, kill craft, respawn, etc...

Now here is my dilemma, what I really want to do is for the enemy to patrol by going to one waypoint, then the next, etc... 4 waypoints in total.  When enemy gets detected, go to him.. and when destroy, respawn another copy of the  enemy that follows the waypoint patrol and so on.
the initial object on scene works fine, but when I respawn, the new object is just stationary. it never goes to the waypoint (I have treid storing the object as a global variable, its vector 3, etc)  Seems (according to what I read on forums) that prefabs loose their connection to scene objects.  Any suggestion on how I can get this working?  seems odd I can make it work following the players vector global variable, bit cant do that to an empty object waypoint.

TheBadFeeling

  • Junior Playmaker
  • **
  • Posts: 66
Re: Need help for Simple enemy aircraft Ai
« Reply #1 on: April 22, 2015, 05:05:35 PM »
Just tell your respawned prefab to start by finding the right object (by tag and/or name or whatever). Prefabs have no relation to scene objects until you tell them what they're looking for. Then you can reference the waypoint like you want and tell it to go to it.

/Bad
The Force is with you, young Playmaker – but you are not a C# senpai yet.

wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
Re: Need help for Simple enemy aircraft Ai
« Reply #2 on: April 22, 2015, 06:06:41 PM »
if u cant figure it out, then you might want to look at ai behavior with playmaker support.  there are others on the asset store as well.  u can do simple ai to really advanced stuff.  really cool.

ricard2798

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Need help for Simple enemy aircraft Ai
« Reply #3 on: April 22, 2015, 06:10:05 PM »
Ok, so i started the FSM with the action:
-Find game object
   (Object name:  Waypoint 8 [this i had to type, since dragging the scene object asked to set properties)
-With tag: untagged (have tried both with a tag and no tag
-Store:  Stored both in a local as well as a global variable of the game object type

following that, i have my itween move to with transform position set to the global variable waypoint 8.

So i run the game,and again... the object that starts in scene works... every other clone that appears after the desctruction of the original one does not move :(

what am i doing wrong?  i am even willing to skype with someone and paypal a small fee to get this working :(

redikann

  • Full Member
  • ***
  • Posts: 174
Re: Need help for Simple enemy aircraft Ai
« Reply #4 on: April 22, 2015, 07:16:45 PM »
A couple ideas would be:

A. Don't destroy the Scene enemy. IF it gets killed hide it  and then reactivate it at a spawn point (resetting any info that you need to).
B. Yes prefabs can't store a reference to scene objects. What you would need is a scene object that acts as a manager. When an Enemy spawns this manager needs to let it know what waypoints are or what object is the player. The manager doesn't get destroyed ever (per scene).

ricard2798

  • Playmaker Newbie
  • *
  • Posts: 13
Re: Need help for Simple enemy aircraft Ai
« Reply #5 on: April 22, 2015, 08:09:34 PM »
REDIKANN YOU ARE AWESOME!!!!
Been trying to get this to work for the longest time, and it never occurred to me to just activate/deactivate objects and reposition them.  It is still not as clean as I would have liked (like a proper respawn would be), but it fdinally worked :)
I might be able to make my oculus mobile vr jam deadlines after all... thanks :)

By the way, if anyone figures out how to do the creating and destruction solution for the objects, please let me know, sicne I anticipate that this method might not work for all my possible scanrios