Vertical Shooters & Enemy Patterns - Pathing
by Doug Linley · in Torque Game Builder · 12/02/2006 (6:54 am) · 5 replies
I am thinking about messing around with a vertical scrolling shooter. I began to think about how the levels and enemies should be handled.
My thought was that I would set up a series of paths at different positions in the level. The level would pan in the negative Y direction. As each path came fully onto screen, the enemies associated with those paths would spawn and be mounted to the paths. They would follow the path to the end node, and if not destroyed they would remove themselves from the level. Each end node would always extend off of the viewable area of the screen.
This led me to a couple of questions.
1. How have some other people handled enemy patterns in vertical shooters with TGB.
2. How do I make an object get rid of itself after reaching the end node? Is there a callback for reaching the end node? I would think that wanting to know if an object reached the end node would be incredibly common.
Thanks in advance for your input.
My thought was that I would set up a series of paths at different positions in the level. The level would pan in the negative Y direction. As each path came fully onto screen, the enemies associated with those paths would spawn and be mounted to the paths. They would follow the path to the end node, and if not destroyed they would remove themselves from the level. Each end node would always extend off of the viewable area of the screen.
This led me to a couple of questions.
1. How have some other people handled enemy patterns in vertical shooters with TGB.
2. How do I make an object get rid of itself after reaching the end node? Is there a callback for reaching the end node? I would think that wanting to know if an object reached the end node would be incredibly common.
Thanks in advance for your input.
#2
Here are some new questions:
1. How have other developers handled creating shooter levels using paths for enemy movement?
2. What is the easiest way to tell if an object has reached the end node. According to the documentation there are no callbacks, but there has to be something in place because of the follow types. Perhaps it's just not exposed. I was thinking you could test the objects x, y and then get the end nodes x, y and compare.
3. Is there a way to create a path, save it - perhaps in a data block - and then call on it later if I want to reuse a path randomly?
12/03/2006 (9:28 am)
Thomas - Thanks for your reply. I should have asked better questions. I have gone through that demo in the past and it's not really what I'm trying to do. The shooter demo spawns enemies randomly and the patterns don't use t2dPaths. I'm looking for something a little more structured.Here are some new questions:
1. How have other developers handled creating shooter levels using paths for enemy movement?
2. What is the easiest way to tell if an object has reached the end node. According to the documentation there are no callbacks, but there has to be something in place because of the follow types. Perhaps it's just not exposed. I was thinking you could test the objects x, y and then get the end nodes x, y and compare.
3. Is there a way to create a path, save it - perhaps in a data block - and then call on it later if I want to reuse a path randomly?
#3
2. Comparing the X and Y wouldn't be a bad route.
3. You could create a template path that's never used for the different types of paths that you want to reuse and then copy one of the templates when you want to use that type of path.
12/04/2006 (6:40 am)
1. I haven't personally seen the code for any shooters in TGB other than the tutorial, but maybe someone else might have some insight.2. Comparing the X and Y wouldn't be a bad route.
3. You could create a template path that's never used for the different types of paths that you want to reuse and then copy one of the templates when you want to use that type of path.
#4
Looking at the source, there are two callbacks you could use. The first and most appropriate is "onPathFinished" called on the PATH with two parameters the first been the ID of the object that has reached the end of the path and the second the node.
If you have the source, have a look at t2dPath.cc in the "preIntegrate" method.
I've not used paths so I can't say for certain this works as you want, but at a glance it does appear like it will do the job for you.
12/04/2006 (10:45 am)
Quote:2. What is the easiest way to tell if an object has reached the end node. According to the documentation there are no callbacks, but there has to be something in place because of the follow types. Perhaps it's just not exposed. I was thinking you could test the objects x, y and then get the end nodes x, y and compare.
Looking at the source, there are two callbacks you could use. The first and most appropriate is "onPathFinished" called on the PATH with two parameters the first been the ID of the object that has reached the end of the path and the second the node.
If you have the source, have a look at t2dPath.cc in the "preIntegrate" method.
I've not used paths so I can't say for certain this works as you want, but at a glance it does appear like it will do the job for you.
#5
Gary - I will definitely check out onPathFinished. This appears to be an undocumented callback. I've searched the documentation and the site and nothing was returned. If an employee could shed light on this it would be appreciated.
Thanks again guys!
12/05/2006 (7:09 am)
Thanks for the replies Thomas and Gary. I'm thinking now more about playing around with generating enemies randomly, but attaching them to template paths as they are created.Gary - I will definitely check out onPathFinished. This appears to be an undocumented callback. I've searched the documentation and the site and nothing was returned. If an employee could shed light on this it would be appreciated.
Thanks again guys!
Torque Owner Thomas Buscaglia