Copying Object in Editor not Copying the Collision Poly?
by Alex Stittle · in Torque X 2D · 12/10/2009 (11:32 pm) · 7 replies
Hi all,
I've set up a rather complex hierarchy of collisions for an object and would like to use that object in multiple places for my level.
However, when I copy the object in TXB using Edit->Copy and then paste with Edit->Paste, the collision poly for the object is not copied to the new instance.
Anyone know why?
I've set up a rather complex hierarchy of collisions for an object and would like to use that object in multiple places for my level.
However, when I copy the object in TXB using Edit->Copy and then paste with Edit->Paste, the collision poly for the object is not copied to the new instance.
Anyone know why?
#2
12/15/2009 (8:49 am)
You can copy and paste them in an text editor like uedit or other at the end of objects in your level file N times and then you will get N same objects when you load the level back in the editor. It just takes you to close and load the editor 1 more time instead of doing the same in editor. The level is xml so you can open and edit even in VC# if you like.
#3
So to save non-programmers time, this is what you copy and paste in Visual Express. On the right hand side menu, go to Content (data), then levels folder. Double click on your level file, which opens up the code.
Copy everything between <StaticeSprite> and </StaticSprite> and then paste it below the last </StaticSprite> (Be sure to also copy the tags. Here is an example of what to copy and paste.
This will be inside of <Objets> </Objects>, which will be inside of <TorqueSceneData> </TorqueSceneData>
After that, in Visual still, go to File, save Data, and I click save all too just in case. Not sure if this is needed, though.
Then go back to TorqueX2D and go to file, Open Scene, then open your LevelData.txscene, or whatever your level scene is called.
Next select your object and move the copy off it. If you pasted many times, then pull those copies off the original as well.
Now I need to figure out how to make paths for sprites to follow and platforms (Collisions the player can jump up through, but collids with when he drops on it.)
12/15/2009 (9:58 am)
Hey, thanks, man. This is totally awesome and works great. I know very little about programming, as I am the artist and level designer, but I was able to figure this out on my own, just by pattern recognition. I had to place objects a few times, check the levelData is Visual Express, then delet the object again in Torque. I had to do that a few times before I regonized what part of the code needed to be copied and pasted. So to save non-programmers time, this is what you copy and paste in Visual Express. On the right hand side menu, go to Content (data), then levels folder. Double click on your level file, which opens up the code.
Copy everything between <StaticeSprite> and </StaticSprite> and then paste it below the last </StaticSprite> (Be sure to also copy the tags. Here is an example of what to copy and paste.
This will be inside of <Objets> </Objects>, which will be inside of <TorqueSceneData> </TorqueSceneData>
After that, in Visual still, go to File, save Data, and I click save all too just in case. Not sure if this is needed, though.
Then go back to TorqueX2D and go to file, Open Scene, then open your LevelData.txscene, or whatever your level scene is called.
Next select your object and move the copy off it. If you pasted many times, then pull those copies off the original as well.
Now I need to figure out how to make paths for sprites to follow and platforms (Collisions the player can jump up through, but collids with when he drops on it.)
#4
<StaticSprite>
<CreateWithPhysics>false</CreateWithPhysics>
<CreateWithCollision>false</CreateWithCollision>
<Components inPlace="true">
<T2DPhysicsComponent type="GarageGames.Torque.T2D.T2DPhysicsComponent">
<Velocity>
<X>0</X>
<Y>0</Y>
</Velocity>
<AngularVelocity>0.0</AngularVelocity>
<InverseMass>1.0</InverseMass>
<RotationScale>1.0</RotationScale>
<ProcessCollisionsAtRest>false</ProcessCollisionsAtRest>
</T2DPhysicsComponent>
<T2DCollisionComponent type="GarageGames.Torque.T2D.T2DCollisionComponent">
<Images>
<T2DPolyImage type="GarageGames.Torque.T2D.T2DPolyImage">
<CollisionPolyBasis>
<Vector2 type="Microsoft.Xna.Framework.Vector2">
<X>-1.00000</X>
<Y>-1.00000</Y>
</Vector2>
<Vector2 type="Microsoft.Xna.Framework.Vector2">
<X>1.00000</X>
<Y>-1.00000</Y>
</Vector2>
<Vector2 type="Microsoft.Xna.Framework.Vector2">
<X>1.00000</X>
<Y>1.00000</Y>
</Vector2>
<Vector2 type="Microsoft.Xna.Framework.Vector2">
<X>-1.00000</X>
<Y>1.00000</Y>
</Vector2>
</CollisionPolyBasis>
<CollisionPolyScale>
<X>1</X>
<Y>1</Y>
</CollisionPolyScale>
</T2DPolyImage>
</Images>
<RenderCollisionBounds>false</RenderCollisionBounds>
<ResolveCollision valueOf="GarageGames.Torque.T2D.T2DPhysicsComponent.BounceCollision" />
<SolveOverlap>true</SolveOverlap>
<CollisionMaterial nameRef="DefaultCollisionMaterial" />
</T2DCollisionComponent>
</Components>
<ObjectType>
<object objTypeRef="t2dSpriteType" />
</ObjectType>
<Pool>false</Pool>
<PoolWithComponents>false</PoolWithComponents>
<IsTemplate>false</IsTemplate>
<IsPersistent>false</IsPersistent>
<Layer>0</Layer>
<Size>
<X>128.000</X>
<Y>128.000</Y>
</Size>
<Position>
<X>126.506</X>
<Y>-154.217</Y>
</Position>
<Rotation>0</Rotation>
<CollisionsEnabled>true</CollisionsEnabled>
<Visible>true</Visible>
<VisibilityLevel>1</VisibilityLevel>
<FlipX>false</FlipX>
<FlipY>false</FlipY>
<SortPoint>
<X>0.000000</X>
<Y>0.000000</Y>
</SortPoint>
<Material nameRef="goodFighter1Material" />
<MaterialRegionIndex>0</MaterialRegionIndex>
</StaticSprite>
12/15/2009 (10:02 am)
Here is an example of what to copy and paste. <StaticSprite>
<CreateWithPhysics>false</CreateWithPhysics>
<CreateWithCollision>false</CreateWithCollision>
<Components inPlace="true">
<T2DPhysicsComponent type="GarageGames.Torque.T2D.T2DPhysicsComponent">
<Velocity>
<X>0</X>
<Y>0</Y>
</Velocity>
<AngularVelocity>0.0</AngularVelocity>
<InverseMass>1.0</InverseMass>
<RotationScale>1.0</RotationScale>
<ProcessCollisionsAtRest>false</ProcessCollisionsAtRest>
</T2DPhysicsComponent>
<T2DCollisionComponent type="GarageGames.Torque.T2D.T2DCollisionComponent">
<Images>
<T2DPolyImage type="GarageGames.Torque.T2D.T2DPolyImage">
<CollisionPolyBasis>
<Vector2 type="Microsoft.Xna.Framework.Vector2">
<X>-1.00000</X>
<Y>-1.00000</Y>
</Vector2>
<Vector2 type="Microsoft.Xna.Framework.Vector2">
<X>1.00000</X>
<Y>-1.00000</Y>
</Vector2>
<Vector2 type="Microsoft.Xna.Framework.Vector2">
<X>1.00000</X>
<Y>1.00000</Y>
</Vector2>
<Vector2 type="Microsoft.Xna.Framework.Vector2">
<X>-1.00000</X>
<Y>1.00000</Y>
</Vector2>
</CollisionPolyBasis>
<CollisionPolyScale>
<X>1</X>
<Y>1</Y>
</CollisionPolyScale>
</T2DPolyImage>
</Images>
<RenderCollisionBounds>false</RenderCollisionBounds>
<ResolveCollision valueOf="GarageGames.Torque.T2D.T2DPhysicsComponent.BounceCollision" />
<SolveOverlap>true</SolveOverlap>
<CollisionMaterial nameRef="DefaultCollisionMaterial" />
</T2DCollisionComponent>
</Components>
<ObjectType>
<object objTypeRef="t2dSpriteType" />
</ObjectType>
<Pool>false</Pool>
<PoolWithComponents>false</PoolWithComponents>
<IsTemplate>false</IsTemplate>
<IsPersistent>false</IsPersistent>
<Layer>0</Layer>
<Size>
<X>128.000</X>
<Y>128.000</Y>
</Size>
<Position>
<X>126.506</X>
<Y>-154.217</Y>
</Position>
<Rotation>0</Rotation>
<CollisionsEnabled>true</CollisionsEnabled>
<Visible>true</Visible>
<VisibilityLevel>1</VisibilityLevel>
<FlipX>false</FlipX>
<FlipY>false</FlipY>
<SortPoint>
<X>0.000000</X>
<Y>0.000000</Y>
</SortPoint>
<Material nameRef="goodFighter1Material" />
<MaterialRegionIndex>0</MaterialRegionIndex>
</StaticSprite>
#5
12/15/2009 (11:15 am)
Ah, great work around Ales! Thanks for your help :)
#6
http://www.youtube.com/watch?v=ExDvAFfnPO0
12/18/2009 (8:58 am)
Here is another way to do it using templates and spawners, which takes no coding at all. It's all done in TX2D. I guess this method also makes the game run smoother. http://www.youtube.com/watch?v=ExDvAFfnPO0
#7
12/18/2009 (9:26 am)
Yes but this is for dynamic objects, i thought you want a solution for static collision objects in level. Making templates through code is a must if you want to control gameplay and spawning of objects and similar. My method is really mostly useful in cases you have more levels and need some objects in all of those levels, for instance why would you want to create the player templates and the AI templates each time (unless they changed) in each level, if you can just copy and paste in uedit and save the level and load it in editor.
Neil Fontaine