Mounting on clone
by Richard Bawden · in Torque X 2D · 09/01/2008 (3:47 pm) · 2 replies
Hi all. I hope someone can help me with something thats driving me nuts.
As a learning exercise I thought I would extend the Space Warrior tutorial to have the projectile fire from the gun of the ship. I have got this working up untill the scene resets.
To do this I wanted to mount a blank scene object to the ship so I could use the position of this create the projectiles.
So I created a blank scene object in TXB and made it a template
Added a Link Point to each ship.
Added a property to the ShipControlsComponent called GunPositionTemplate and gave it the name of the blank object I created.
Then in the OnRegister method in the ShipControlsComponent I do
_gunObject = GunPositionTemplate.Clone() as T2DSceneObject;
TorqueObjectDatabase.Instance.Register(_gunObject);
_gunObject.Mount(SceneObject, "LinkPoint1", true);
then I use _gunObject.Position when I create my projectile.
As I say this all works fine untill the scene resets. Then for some reason the projectile always fires from it's original location like it is no longer mounted, but is created in the right location.
Thanks very much for sticking with me this far, hope someone can help.
As a learning exercise I thought I would extend the Space Warrior tutorial to have the projectile fire from the gun of the ship. I have got this working up untill the scene resets.
To do this I wanted to mount a blank scene object to the ship so I could use the position of this create the projectiles.
So I created a blank scene object in TXB and made it a template
Added a Link Point to each ship.
Added a property to the ShipControlsComponent called GunPositionTemplate and gave it the name of the blank object I created.
Then in the OnRegister method in the ShipControlsComponent I do
_gunObject = GunPositionTemplate.Clone() as T2DSceneObject;
TorqueObjectDatabase.Instance.Register(_gunObject);
_gunObject.Mount(SceneObject, "LinkPoint1", true);
then I use _gunObject.Position when I create my projectile.
As I say this all works fine untill the scene resets. Then for some reason the projectile always fires from it's original location like it is no longer mounted, but is created in the right location.
Thanks very much for sticking with me this far, hope someone can help.
Torque Owner Richard Bawden
I found that I had marked the blank scene object as 'pool with componants'
Hope this saves someone some time someday.