Naughty spawner
by Dan Pascal · in Torque X 2D · 10/30/2007 (6:48 pm) · 8 replies
Car hits robot and robot is stuck on car as it drives by
I got a sprite marked as a template (the sprite is a car)
I set up a link point on it
I make a spawner object for it
I create another sprite (the mangled robot), mark it as a template
I make a spawner object for that and then mount the spawner object to the car template sprite.
On the mangled robot spawner I uncheck enable Spawn and I uncheck Spawn Once
The car spawns(good) and the mangled robot spawns with it (bad), I can't disable it from spawning!!?
I have a component on the car template. In the _OnRegister section I put a call to find my mangled robot spawner so I can reference it.... but it never finds it. ( torqDatabaseFindObject<>). I can find all other objects though...
When the car template spawns and _onRegister is called should it be able to find the other spawner mounted to it, or should it not because the mounted spawner hasn't spawned yet?
someone show me the way
Many thanks
I got a sprite marked as a template (the sprite is a car)
I set up a link point on it
I make a spawner object for it
I create another sprite (the mangled robot), mark it as a template
I make a spawner object for that and then mount the spawner object to the car template sprite.
On the mangled robot spawner I uncheck enable Spawn and I uncheck Spawn Once
The car spawns(good) and the mangled robot spawns with it (bad), I can't disable it from spawning!!?
I have a component on the car template. In the _OnRegister section I put a call to find my mangled robot spawner so I can reference it.... but it never finds it. ( torqDatabaseFindObject<>). I can find all other objects though...
When the car template spawns and _onRegister is called should it be able to find the other spawner mounted to it, or should it not because the mounted spawner hasn't spawned yet?
someone show me the way
Many thanks
About the author
#2
Thanks John!
This is for an update on the green robot video tutorial series. That test piece really spells it out, this should do the trick...
10/31/2007 (9:06 am)
Excellent-Thanks John!
This is for an update on the green robot video tutorial series. That test piece really spells it out, this should do the trick...
#4
Works like a charm.
www.danpascal.com/carHit.zip wmv 1mb
11/01/2007 (9:01 am)
Here's a clip of it in action. Works like a charm.
www.danpascal.com/carHit.zip wmv 1mb
#5
John K.
11/01/2007 (2:40 pm)
Wow, that video looks great! I Love that lingering robot arm left behind on the road ;) - kind of reminds me of a futuristic next-gen Frogger. Great Job!John K.
#6
11/01/2007 (3:30 pm)
What game is this, I'm very curious...
#7
11/02/2007 (8:27 am)
It's the next installment of the green robot video deal
#8
11/06/2007 (1:17 pm)
Nice video Dan, I love it! :)
Associate John Kanalakis
EnvyGames
The only workaround I can think of is to start off with the mangled robot template that is invisible (and has no collision enabled) initially mounted to the car spawner. Then when the car hits the robot, you make the hit robot invisible and at the same time, make the mounted corpse visible in one swoop... something like this:
public static void ProcessRobotCollision( T2DSceneObject myObject, T2DSceneObject theirObject, T2DCollisionInfo info, ref T2DResolveCollisionDelegate resolve, ref T2DCollisionMaterial physicsMaterial) { //hide the standing robot theirObject.Visible = false; //delete the standing robot theirObject.MarkForDelete = true; //get the list of mounts List<T2DSceneObject> list = new List<T2DSceneObject>(); myObject.GetMountedObjects("", list); //make the already mounted corpse visible list[0].Visible = true; } [TorqueXmlSchemaType] public static T2DOnCollisionDelegate RobotCollision { get { return ProcessRobotCollision; } }Just add the RobotCollision OnCollision delegate to the car's T2DCollisionComponent and make the collision object type match the standing robot object type.
You can try my simple test.
Since I don't know the specifics of your game, I'm not positive if this "workaround" will do. But, I can tell you that I'm seeing the same problem you are and that it's not how I expect the spawner to behave.
John K.