Jump to content

Launch Clamp How-To (Tutorial)


Recommended Posts

Launch Clamp How-To (Tutorial)

 

I'll probably add detail later, but I wanted to at least get this started. Launch Clamps are one of the more tricky things to make, second only to landing gear/legs, but not nearly as hard. However, you do have to get a lot of the details right. Positions and orientations of transforms matter a lot, and nothing will work right if you get some of the details wrong.

 

An excellent starting point is the FASA Launch tower tutorial by @frizzank, and in fact that's where I learned to make them. At the time that I made the launch clamps for SpaceY, I followed that pretty closely and ended up moving things around in Unity to make it work. Today I rearranged it in Blender so that nothing has to be done in Unity afterward.

 

So this is a "How-To" using my "new method", from Blender. There are probably other ways of doing this, and in some minor ways it differs from the FASA setup, slightly. However just like the FASA tutorial, let's look at the CFG setup first, then what you need to make in Blender afterward.

 

MODULE
{
	name = LaunchClamp	// Module name. DO NOT CHANGE.
	
	trf_towerPivot_name = Cap     // Rotation transform that the tower connects to.
	trf_towerStretch_name = Tower // Transform that gets stretched to make the tower.
	trf_anchor_name = Base        // Transform that connects to the ground.
	
	trf_animationRoot_name = SYclamp1new  // Transform that contains the animation 
                                          // and all animated parts, at some level.
	anim_decouple_name = clamp            // Name of the retraction animation itself.
}

 

This is pretty straightforward. The "Cap" is the top of the tower, the part that connects to the clamp itself. The "Tower" is a transform that contains all of the stretchy tower meshes. The "Base" is what sits on the ground, and it will need to contain a collider. The Base's collider acts like a foot and keeps the clamp from twisting, however the clamp's "attachment" to the planet is actually at the Cap's origin, or close to it. Yes, it's a hovering object, technically. :)

 

So first, in Blender, create four (4) empty transforms. You can hit Shift-A and select "add empty" for each one. Then give them these names:

  • Cap, Base, Tower, Clamp

The "Clamp" transform is really just a place to group your animated and non-animated meshes for the clamp itself. Now we'll talk about each one, and what goes in it. Each mesh object you make needs to be a child of one of these transforms (though like I said, "Clamp" is just for organizational use in this case). In Blender, I'm assuming you're working in the default orientation with +Z going up. I do the export as an animated FBX, to import into Unity. Let's start at the bottom and work up:

(After importing, the Cap, Base, and Tower transforms will need to have a rotation of 0,0,0 or something "close" to it, either with floating point rounding errors, or some "360" or "-360" values. The "X=90" rotations below are for Blender, so that it gets rotated properly during import to Unity).

 

Base

This transform's position must stay at 0,0,0, and it needs a rotation of X=90. As children of it, you will need two mesh objects:

  1. One for the base artwork itself, most of which will extend into the ground, but with the visible "foot" of the tower included. Usually this mesh should be designed to have several meters worth that extends into the launch pad, so that if you build a large rocket, and the clamp is placed outside of the pad, the length still reaches the ground outside of the launchpad. Extending down to -6m is probably sufficient.
  2. A simple mesh collider that corresponds to only the part of the base/foot that should be above the surface of the launch pad. You can add this later in Unity as a box collider or something if you want, but I use a custom mesh collider here. If you try to make this collider too tall, and encompass the part of the Base that is meant to extend under the launch pad, then the entire thing will "jump" upward to make sure the entire collider is above the pad when it spawns. The bottom of the collider should be at a height of exactly zero (0).

Keep in mind that 0,0,0 is the surface of the launch pad. The visible part of the base/foot needs to be above Z=0, and the rest of the base that's hidden inside the pad will be below Z=0.

(Note: The Base, Tower, and Cap transforms will never be rotated relative to the launch pad. They do not rotate with your clamp's deployment orientation.)

 

Tower

This transform's origin position will be at the bottom of the cap's mesh, and the top of the tower's mesh, centered over the base, at 0,0,Z, where Z is a height that you will define. It has a rotation of X=90. This transform moves with the Clamp and Cap, but is scaled in height so that it can always reach the ground.

You can add the visible mesh directly to this transform, probably, but I make a separate mesh object that is a child of it. The Z coordinate for the Tower transform should be above the origin by some number of meters, with enough height to create a tower mesh object from there toward the ground, extending below 0,0,0 a little bit. This mesh's top edge must terminate exactly at the Tower transform's origin. That is, the top edges must not be above or below the Z height of the Tower transform. This is very important, since the mesh is being stretched by scaling it from the Tower transform's origin coordinates, any errors with regard to the top of the mesh will be amplified when the launch clamps are used high off the pad, and will not line up with the Cap.

The texture used by the Tower's mesh needs to be repeating along the Y-axis. As the mesh gets stretched, the texture does not get stretched, but rather "tiled" vertically. It's OK to have UVs that use different X positions for different things, but the entire Y-height of the texture needs to be a vertically repeating pattern.

(Note: The Base, Tower, and Cap transforms will never be rotated relative to the launch pad. They do not rotate with your clamp's deployment orientation.)

 

Cap

This transform's origin needs to be at 0,0,Z (Rotation is X=90), centered over the Tower and Base, with Z at a height that you define. This height should correspond to the attachment point at the front of your clamp, for sanity, since this is where your clamp's head will pivot. The Cap will have two main things as children of it:

  1. A mesh object that acts as the "cap" to the Tower stretchy-mesh. It should look like it's a part of the same object, artwork-wise. The bottom of this mesh should match up with the origin of the Tower transform, and extend high enough that no matter which way the Clamp's head gets turned around (on any or all three axes) that there's never a gap or missing or hollow mesh visible. When you attach the launch clamps to a rocket or plane, by default the clamp's head is rotated to correspond to the part it's attaching to, even if that means the clamp sits sideways or upside-down.
  2. The Tower transform and its children. The Tower transform is a child of the Cap transform.

(Note: The Base, Tower, and Cap transforms will never be rotated relative to the launch pad. They do not rotate with your clamp's deployment orientation.)

 

Clamp

This can contain all of the mesh objects and colliders needed for the actual clamp. All animated parts for the clamp retraction will be in here. The colliders that you will "grab" in the VAB will be here. This is the easiest part, since it functions just like a normal animated part in KSP. I usually orient the transform/meshes such that the clamp is oriented with the +Y direction toward the back of the clamp, and -Y in the direction toward the rocket. As far as I can tell it doesn't appear as though KSP cares as much about the positions and orientations of anything other than Cap, Tower, and Base, and therefore you can pretty much do what you want with the head/clamp components. This part of the clamp will function like a surface-attached part, with the Cap/Tower/Base hanging down from the clamp.

 

Putting it together

Export from Blender, import into Unity like you would for any other part. In Unity's assets, select the model, set it to Legacy animation (as usual), scale of "1", and name your animation to match the name you used in the part module for the CFG. Export as a MU as normal.

 

Screenshots of the SpaceY launch clamp:

 

Link to comment
Share on other sites

Necro i have been at this launch clamp tutorial for 2 solid days. I have read and triple read the tut step by step. I have some questions

Does the launch clamp have to have animations associated with it in order for it just to stretch the mesh correctly?

when you export in .FBX format in blender what are the Axis set at? -Z forward Y-up? I would asume Z forward Y up for unity.

In blender in the right panel the outliner hierarchy panel you have a wrench icon next to the mesh objects indicating a modifier. Is this a collision modifier? If so any special settings you used?

After you import the .FBX into unity are you still clicking on "generate colliders"? Is there only a collider for the base? are you checking "Convex"? Is there one for the cap also?

Edited by Redneck
Link to comment
Share on other sites

  • No animation is needed.
  • -Z forward Y-up
  • No such modifier needed.
  • Don't click on "generate colliders". Colliders are set up as meshes in blender and you remove the renderer from them and assign a mesh collider (convex ticked) to them.
Link to comment
Share on other sites

@Redneck -- InsaneDruid answered most of those, so I'll answer the other questions.  I don't put colliders on the Cap, but I think you can probably add one if you want. Strictly speaking, I think you could also get away with leaving off the collider for the Tower if you wanted, but allowing things to pass through it would be silly. :wink: I put colliders for the Tower and Base, and any needed colliders for the Clamp.

 

The "Tower" doesn't use animations at all, it's simply scaled vertically based on the height of its transform's "origin" from the ground, depending on where the clamp is deployed. So as long as mesh stretches from the transform origin, all the way to the actual origin (0,0,0), it should line up correctly and never leave any gaps.

 

The wrench icon is there because I added an "edge split" modifier to those meshes, which just saves some time over manually defining which edges are rounded versus sharp. It's completely up to you as to whether you need to add that.

 

When exporting as FBX, mostly the defaults work. I'm using a copy of Blender that's a year and a half old, and I know they changed some of the exporting options in newer versions. But I use the defaults except for checking "Selected Objects" (making sure I've selected everything in Object Mode by hitting "a", which will select everything I haven't explicitly hidden from view) and then unchecking "All Actions".

 

Link to comment
Share on other sites

I have Tried everything I can think of and no luck. So instead of trying to describe in a lengthy post what I have and have not tried etc I thought i might just link the blender file and the Unity project folder (unzip test2 to hardrive somewhere and open unity and point it to test2 folder). Can somebody take a look at it and tell me what I am doing wrong? The blender file was done with version 2.71

https://www.dropbox.com/sh/ilumkf14a082wz1/AADnRNPp-NJIK0yxTdH8xNUAa?dl=0

Link to comment
Share on other sites

23 hours ago, Redneck said:

I have Tried everything I can think of and no luck. So instead of trying to describe in a lengthy post what I have and have not tried etc I thought i might just link the blender file and the Unity project folder (unzip test2 to hardrive somewhere and open unity and point it to test2 folder). Can somebody take a look at it and tell me what I am doing wrong? The blender file was done with version 2.71

https://www.dropbox.com/sh/ilumkf14a082wz1/AADnRNPp-NJIK0yxTdH8xNUAa?dl=0

 

Most of it looks pretty good to me. The only thing that leaps out at me is that you have everything nested under a transform called "launchTower2", which is centered somewhere off of the origin and also has its own X=90 rotation. One experiment worth trying might be to drag everything out from that transform, so you can delete it, and see if that helps. I don't know how KSP will behave with everything nested under a non-centered transform.

Link to comment
Share on other sites

8 hours ago, NecroBones said:

 

Most of it looks pretty good to me. The only thing that leaps out at me is that you have everything nested under a transform called "launchTower2", which is centered somewhere off of the origin and also has its own X=90 rotation. One experiment worth trying might be to drag everything out from that transform, so you can delete it, and see if that helps. I don't know how KSP will behave with everything nested under a non-centered transform.

yeah that transform was me resorting to desperation. The stock launch clamp by squad has it like that so I tried it. But before that originally  I wasnt using it with same results. here is the .cfg Ive tried changing LaunchClamp Module

PART
{
	name = Launch_Tower
	module = Part
	author = Redneck
	mesh = Launch_Tower.mu
	rescaleFactor = 1
	scale = 1
	node_attach = 0.0, 3.981364, 3.615985, 0.0, 0.0, -1.0 
	fx_gasBurst_white = 0.0, 1.354437, 0.8369194, 0.0, 0.0, 1.0, activate
	sound_decoupler_fire = activate
	
	// --- editor parameters ---
	TechRequired = generalConstruction
	entryCost = 1800
	cost = 200
	category = Structural
	subcategory = 0
	title = Launch Tower
	manufacturer = Redneck Rockets
	description = Launch Tower
	attachRules = 0,1,0,1,0
	
	// --- standard part parameters ---
	mass = 0.1
	dragModelType = default
	maximum_drag = 0.2
	minimum_drag = 0.2
	angularDrag = 2
	crashTolerance = 100
	maxTemp = 2000 // = 5000
	fuelCrossFeed = False
	explosionPotential = 0.1
	breakingForce = 150
	breakingTorque = 150
	stageOffset = 0
	childStageOffset = 0
	bulkheadProfiles = srf
	tags = clam hold )pad rocket stabil tower
	
	MODULE
	{
    name = LaunchClamp  //name of the module do not change
	trf_towerPivot_name = Cap	//Name of the rotation transform that the Tower part is linked to
	trf_towerStretch_name = Tower //Name of the mesh that gets stretched
	trf_anchor_name = Base //Name of the mesh that snaps to the ground
	//trf_animationRoot_name = Walkway_Anim_Root //the empty game object that holds the animation and the animated 
	//anim_decouple_name = Launch_Tower_Anim // name of the animation to play
    }

	MODULE
	{
		name = ModuleGenerator
		isAlwaysActive = true
		OUTPUT_RESOURCE
		{
			name = ElectricCharge
			rate = 1
		}
	}

	MODULE
	{
		name = ModuleTestSubject
		useStaging = True
		useEvent = False
		situationMask = 4
		useProgressForBodies = False
		usePrestigeForSit = False
		CONSTRAINT
		{
			type = SITUATION
			value = 4
			body = _Home
		}
		CONSTRAINT
		{
			type = SITUATION
			value = 0
			body = _NotHome
		}
		CONSTRAINT
		{
			type = REPEATABILITY
			value = ONCEPERPART
		}
	}
}

 

Link to comment
Share on other sites

7 minutes ago, Redneck said:

yeah that transform was me resorting to desperation. The stock launch clamp by squad has it like that so I tried it. But before that originally  I wasnt using it with same results. here is the .cfg Ive tried changing LaunchClamp Module

I see you have trf_animationRoot_name and anim_decouple_name commented out. You'll definitely need those. I didn't try loading up your Unity object, but this can definitely be a prickly part of the process. When you import the FBX (or whatever) from Blender, you'll need to give the animation a name in Unity, and use that name for "anim_decouple_name". The "trf_animationRoot_name" will get the name of the object that has that animation, which after importing your model, it will usually have the name of the Blender file. If you'll notice in my screenshots and config example, mine is called "SYclamp1new", which was the name of the ".blend" file, and so that's the default name of its root transform when adding it to a GameObject. In the screenshot I have that transform selected, and you can see that it's the one that has the animation.

 

Link to comment
Share on other sites

7 minutes ago, NecroBones said:

I see you have trf_animationRoot_name and anim_decouple_name commented out. You'll definitely need those. I didn't try loading up your Unity object, but this can definitely be a prickly part of the process. When you import the FBX (or whatever) from Blender, you'll need to give the animation a name in Unity, and use that name for "anim_decouple_name". The "trf_animationRoot_name" will get the name of the object that has that animation, which after importing your model, it will usually have the name of the Blender file. If you'll notice in my screenshots and config example, mine is called "SYclamp1new", which was the name of the ".blend" file, and so that's the default name of its root transform when adding it to a GameObject. In the screenshot I have that transform selected, and you can see that it's the one that has the animation.

 

Ok so I got rid of that one transform that everything was parented to and undoing the animation comments. will assign some random animation to it and name it correctly and see what happens

 

Edited by Redneck
Link to comment
Share on other sites

  • 2 weeks later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...