Game Development Community

Spawner attached to Template

by Henry Shilling · in Torque X 2D · 07/15/2009 (5:52 pm) · 4 replies

I have created some spawning ships, I would like these spawning motherships the launch some small attacking ships. So I attach a spawner to my Mothership, and while it does spawn ships, they do not fly off and attack my ship. They sit and rotate as if they are ready to attack, but they do not detach. So like I would say there is no way to attach a spawner to another object and have the spawned objects move away? I guess I'd have to make the fighter ships, spawn like projectiles?


#1
07/15/2009 (7:58 pm)
I'm not sure exactly what you're asking- I'm envisioning it like a (1) Aircraft carrier at sea, and (2) aircraft come up from below deck to (3) sit on top of the carrier and then (4) the aircraft launch from the carrier and (5) the carrier deck is empty for some amount of time.

It seems like it would be cleaner to have separate animations:
So, (1) Idle/Moving animation of boat
(2) Animation of carrier opening up and a plane coming up
(3) Animation of Idle carrier with a plane on top
(4) At this point I'd say the animation would go back to (1) with no transitions, and you would grab vectors, etc. to create a spawner at the exact location of where the animation placed the plane, and the plane takes off
(5) Then the spawned plane is gone and the animation returns to (1) (although it has been at one since (4)

Hopefully that's understandable. I used a carrier just because it's easier for me to visualize and describe. Would this work?
#2
07/15/2009 (9:07 pm)
Here is what I thought I could do. (oddly enough it it an aircraft carrier)

I have Template of carrier, attach spawner that spawns planes to carrier. The planes should fly off! but they just sit there like the turrets on the battleships and rotate. So I should be happy that the turrets don't fly off, they rotate and shoot as they should. Plus I guess if the planes were spawned by the carrier, when the carrier is destroyed they planes would be destroyed.

So I am spawning the planes in code, basically the same way I'd spawn a projectile.

Basically this was just a mental exercise on how could I do this in the TXB. If I could then it would be easy for me to hand the TXB to my son (artist) and let him build the level, and it would just work.
#3
07/16/2009 (4:04 am)
Hey Henry,

I have not verified this at all, but I'm assuming when you say "attached" you mean that you have mounted the objects together. If this is the case, my guess is that when you are doing the cloning, the clones are also mounted.

When this happens, the mounts pretty much share the velocity and positions of their mount parent (or what their mounted to) so they won't move from their original positions.

To solve this I think you can just manually unmount the spawned objects programmatically (I don't have the exact syntax handy for that at the moment unfortunatly) and they should then move away from the aircraft carrier.
#4
07/16/2009 (10:18 am)
I don't know about clones being mounted; I've mounted a spawner before as a weapon and it spawned the bullets fine. When the fighters are cloned, you are then registering them with the TorqueObjectDatabase, right? Then it should consequently call the OnRegister method for any component attached to the fighters... I presume you have some sort of component attached to control them, correct?

Where exactly in your code do you set the velocity for these fighters?