playMaker

Author Topic: Spawner waypoint problem that I can't solve...  (Read 3863 times)

Horror

  • Junior Playmaker
  • **
  • Posts: 79
Spawner waypoint problem that I can't solve...
« on: June 13, 2012, 05:12:30 AM »
Okay, I wanted to solve this myself but I can't think of a clean way to handle it and the problem is really doing my head in now! :/

I have a Spawner GameObject with a Waypoint GameObject as a child.

I also have an Enemy GameObject.

What I want to do is create the Enemy at the Spawner and then move it to the Waypoint. The problem is that there are going to be several of these Spawners and I need to be able to have the Enemy find the Waypoint belonging to the Spawner which created it.

Is there some way I can create a unique ID for each Waypoint and then pass that ID to each Enemy that the spawner creates? I have no idea how to go about doing something like this.

Any help would be appreciated! Cheers :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Spawner waypoint problem that I can't solve...
« Reply #1 on: June 13, 2012, 05:32:12 AM »
Hi,

 What framework are you using, when you talk about waypoints, spawn points? Are they yours?


 Bye,

 Jean

Horror

  • Junior Playmaker
  • **
  • Posts: 79
Re: Spawner waypoint problem that I can't solve...
« Reply #2 on: June 13, 2012, 07:14:39 AM »
Yes, these are just GameObjects that I have made and want to use as a target for my enemies. I'm not using any pathfinding system, I shouldn't really need it for this project. Because the player can't move, I'm bascially spawning the enemies out of sight and then moving them into view with the waypoint. When they get there they just beeline straight for the player.
« Last Edit: June 13, 2012, 10:07:16 AM by Horror »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Spawner waypoint problem that I can't solve...
« Reply #3 on: June 13, 2012, 11:05:10 AM »
Hi,

 ok, what are the criteria for an ennemy to find a way point? Once I know that I will be able to help you more.

Is it the closest waypoint from the ennemy spawn point, or something more contextual, for example based on the number of ennemy.

Bye,

 Jean

Horror

  • Junior Playmaker
  • **
  • Posts: 79
Re: Spawner waypoint problem that I can't solve...
« Reply #4 on: June 13, 2012, 06:24:24 PM »
I don't really want it to find the closest waypoint since there's no garauntee that the closest waypoint is the one that I want them to move to. Every spawner has its own waypoint and this is where I want the enemy to move to.

I had an idea during my not to restful sleep last night. I'll have to wait until I get home from work to try it...

What if I:
-Add a trigger around the spawner, as a parent of the waypoint. Get Child and store the waypoint as a variable.
-When the enemy spawns, it enters the trigger; The trigger uses the variable to Set Child the enemy to the waypoint.
-The enemy does a Get Parent to store the waypoint as a variable for its Move Towards location.

Maybe? :P

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Spawner waypoint problem that I can't solve...
« Reply #5 on: June 14, 2012, 01:18:52 AM »
Hi,

 still a bit unsure about the theoretical mechanism behind choosing a way point.

as for your idea, it won't work since if you create an object within the bound of a collider, it will not detect the collision (correct me if I am wrong tho, but that's my experience of it).

 Is it not a case of simply maintaining a reference of the waypoint for each spawner? create a "spawner" fsm, add a gameObject variable name "waypoint", drag and drop the waypoint for that spawner, and then you will know where to go.

 bye,

 Jean

Horror

  • Junior Playmaker
  • **
  • Posts: 79
Re: Spawner waypoint problem that I can't solve...
« Reply #6 on: June 14, 2012, 04:13:11 AM »
I would like to do something similar to what you have suggested but how would I send that waypoint variable to the enemy? With your suggestion only the spawner would know about the waypoint. The enemy is spawned as a separate GameObject and knows nothing about the spawner that created it. Unless there is a way to find out which GameObject created another GameObject, or to inherit properties from the object that created it, I'm not sure how I would make this work.

Horror

  • Junior Playmaker
  • **
  • Posts: 79
Re: Spawner waypoint problem that I can't solve...
« Reply #7 on: June 14, 2012, 06:52:05 AM »
My crazy trigger idea seems to work!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Spawner waypoint problem that I can't solve...
« Reply #8 on: June 14, 2012, 08:51:42 AM »
Hi,

 Good!

to answer your last question, At some point in your process, you will have to create an ennemy and tell it to be spawned at a specific position, this is where you should store the ennemy gameObject you just created, and send it an event to tell it which waypoint it should go, you can fill events with data, so you would store the waypoint in the event data, fire an event "GO TO WAYPOINT" to that ennemy gameObject and it would implement that event, get that waypoint and mot to it.

https://hutonggames.fogbugz.com/default.asp?W531
https://hutonggames.fogbugz.com/default.asp?W530

 but if you have solved it already, perfect!

Bye,

 Jean

Horror

  • Junior Playmaker
  • **
  • Posts: 79
Re: Spawner waypoint problem that I can't solve...
« Reply #9 on: June 15, 2012, 11:25:40 AM »
Thanks Jean :)