Jump to content

C7 Tutorials


Recommended Posts

Hello there! I\'ve been working on some video tutorials to celebrate the release of KSP .15.

In this first Video, I\'ll show you how to build a basic spaceplane, take off, and finally land (sort of). I\'ll also be showing how to use the new trim controls, part rotation and symmetry modes that have been added.

This is the first tutorial in regards to modding for KSP .15. I\'ll go over setting up the new part tools for Unity game engine. In addition I\'ll show how to import and export a file for use in the game.

Now, this is the part that I need your help on! Please let me know if there is anything I can do to improve these videos. I\'ll be covering more advanced topics in the coming weeks, including setup of emissive shaders and Unity Animation on Parts. Additionally I can go into more depth on SpacePlane construction techniques.

Thanks,

C7

Link to comment
Share on other sites

Also, please don\'t hide the cursor in FRAPS (or whatever program you are using), as it is very helpful to follow the cursor around on screen, instead of not being sure what you click on :) Also, there is a tiny bit of noise, and your voice isn\'t as clear as it maybe could. If you could speak up just a little, that would help at least for us with headphones :)

A tutorial on how you make the landing gear behave properly when opened, and how you define it to take damage when closed and landing, would be great.

How do you, in Unity, tell the item to reverse the animation when activated again?

Could you also give a step-by step on how to create a working sattelite? (A sattelite with a function, and an animation (solar panel expanding?). Can be as 'easy' as a blue box with a flat panel attached), and then show clips of it working in the game?

Link to comment
Share on other sites

Nice tute. Well commented. I havent built a plane yet because all those parts are intimidating. You didnt say which part you used or why you used it. If you\'re extra caring you can attach your craft so we can mess with the same plane we saw you build. :)

Good job. :)

Link to comment
Share on other sites

Ok...something i\'m confused on and I\'d love to see a video explanation(a written one would be fine though)-

Engines seem to work basically with just the following-

Fuel tank

Thruster.

In the vid you have-

Fuel tank

Thuster

Intake.

They are configured like so intake/fuel/thruster.

Now then,

Question one

What do the actual 'engine' parts do then and where/how/why would I use them? There seem to be 2 different ones and I have no clue how they differ or what effect they actually have.

Question two

How much does part order matter?

For example if I set up a plane that front to back is-

Intake/cockpit/Engine/Fuel/Thruster

It works, but I don\'t know whats doing what or whats actually helping. Does that intake do anything, or does the cockpit prevent it from helping? Is that engine doing squat, or am I just getting normal fuel + thruster output?

I\'d love to screw with spaceplane stuff more, but I\'m having a hard time figuring out what in the hell is going on.

Link to comment
Share on other sites

Well for now. The intakes do nothing, and the engine bodies do nothing. They\'re mostly there as an attachment point and in the case of the intakes, aesthetics. So you can quite readily leave them out if you like.

Currently the engines just need fuel to run, and nothing more. In the second revision of the engines they are running off of air provide by connected intakes. In short, they do nothing now, but they will in the near future.

Link to comment
Share on other sites

Well for now. The intakes do nothing, and the engine bodies do nothing. They\'re mostly there as an attachment point and in the case of the intakes, aesthetics. So you can quite readily leave them out if you like.

Currently the engines just need fuel to run, and nothing more. In the second revision of the engines they are running off of air provide by connected intakes. In short, they do nothing now, but they will in the near future.

So in the second revision, the turbojet/ramjet engines won\'t work from the runway?

Link to comment
Share on other sites

I have a question which is probably be more appropriately asked elsewhere, but the part creation video raises it for me, and you may know the answer:

You mention in your video simply generating the collider mesh in Unity and selecting convex (which builds more tris than I would think :o ). I\'ve noticed the physx simulation is basically the performance sink in this game (and I imagine any simulation based game built on Unity). I don\'t have enough experience to know, is the number of polys in the collider going to add 'significantly' to that performance hit? If I were to create, say, a 12 tri cube to surround the gear bay, would it boost the performance (measurably)? I\'m mostly referring to assemblies with many parts. Is the number of colliders more important than the number of triangles building up those colliders? For instance, considering 6 72 triangle colliders versus 36 12 triangle colliders; would there be a noticeable difference? Should I take considerable time to optimize the collider?

Link to comment
Share on other sites

Not too sure about this, but I guess the more triangles a collider contains, the more time it requires to detect collisions, though I don\'t know for multiple colliders.

I also have a question for you, C7: How do multiple colliders work in a single part? In the video, you make a convex collider for the gear bay, but how does it not intersect the wheel\'s collider when it retracts? Or are colliders in a single part allowed to pass through one another?

Link to comment
Share on other sites

Here\'s an example from Unity itself. You can have multiple colliders linked to one rigidbody, and they will not cause a collision with each other. The forces of impact with another body will transfer to the core rigidbody. Essentially a wheel collider isn\'t a 'real' collider anyways. But even it if was, it wouldn\'t be a problem.

class-BoxCollider-2.jpg

Mesh Colliders are very 'heavy'. The more triangles they have the more vertices that need to be checked against etc. Unless your model is perfectly convex and made of perfect quads, you can expect it to get a little messy when Unity processes it. In most cases its faster to use multiple primitive colliders, since the internal bounds are easily 'known'. The case above is likely more efficient by far then a mesh collider would be. I\'d like to use more compound primitive colliders like this, but its difficult to do with the new part attachment logic.

Link to comment
Share on other sites

Ok. I made my part, and I exported it, but now I can\'t find the directory I exported it to.

I exported to Parts/(partname)/model.mu.

Should I be exporting to C:/Program Files/KSP_Win/Parts/(partname)/model.mu?

What the heck? For some reason it was exporting to the sample project. Any idea how to fix that?

Link to comment
Share on other sites

It exports to the root folder of your Unity project. Which is sort of how unity does things ;). Just copy it over to your KSP folder when you\'re ready to use it in game.

Ok. Well, I can say the part works successfully. I guess I should move on to emissives and animation next. ;D

Link to comment
Share on other sites

C7 Why is it that when ever i make a plane i either get too much lift (the second i try to take off i do a flip and explode) or not enough lift (when i try to take off i dont get enough lift and my engines explode from hitting the ground) and how can you have enough fuel to even THINK about getting to space!!! The highest I\'ve ever gotten was 10,000m!

Link to comment
Share on other sites

Spaceplanes are quite hard. If you\'re having a craft that flips over, its not because of too much lift. Its because the aircraft is imbalanced. Now if you can\'t make it off the runway, one of many problems is occurring. Either you don\'t have enough thrust / lift. Or your have a negative angle of attack on your wings. If the craft is nose down, this often happens. Try angling your wings up a bit to help get you off the runway. Also, try posting a craft you\'re having problems with the spacecraft exchange. Its hard to tell you what you need to do, unless we can see what the problem is.

Link to comment
Share on other sites

One more question; My animation is fine, when 'played automatically,' it plays until it stops. In fact it plays in the part selection window the moment the part is selected. It even animates the second collider as expected (correctly allowing for surface attachments). Animate physics is currently checked.

Having unchecked that, how in my module can I play it manually? Currently


protected override bool onPartActivate()
{
//this.animation.enabled = true; //commented because this is now deprecated.
this.animation.Play(); //does nothing
//this.animation.playAutomatically(); //also does nothing

return base.onPartActivate();
}

doesn\'t do anything when the part is activated (except for play the activation sound effect correctly).

The only thing I can think of is that the second collider does share space with the main body collider. Per C7s earlier statement that colliders on a single game object will not collide with each other, I assume this is fine.

Additionally, as was asked earlier, how can I run it in reverse if I want to?

[Edit]: So close!


Animation[] allAnimations = this.FindModelAnimators( 'Default Take' );
if( allAnimations != null )
print( allAnimations.Length.ToString() );
else
print( '\nNone Found\n' );
allAnimations[0].animatePhysics = true;
allAnimations[0].Play();

M0c9x.jpg

My bomb didn\'t move with the arm, but it\'s only a matter of time and Debug Prints (hopefully);

I\'m pretty sure that to run it in reverse, I may have to set up a second 'Take,' although I\'m not sure how to set up a second animation in Blender that will be properly imported (Probably as Default Take.001' or something similar).

[Edit]: Well, here\'s how I got it to play the second part of the animation on command:

I set up the entire animation in Blender.

q3Qcp.png

Note that I went through the whole DopeSheet-->Action Editor-->NLA Editor since I never had before, but I\'m reasonably certain you don\'t have to, though. Just animate the full range of motion with a beginning, middle, and end, where the middle is the deployment and the end is the return to the initial state.

Split the animations in Unity by selecting the main part import in Projects, then inspect. choose Split, then choose the Deployment animation, add a second one as the Retraction animation. Keep in mind that it doesn\'t seem matter what you call them.

J2HbV.png

Finally; in whatever code block you are using to run the animation clips, you can put something like this (I don\'t doubt there\'s a more correct way to do it, but if there is, I haven\'t found it yet):



Animation[] allAnimations;
string[] clipNames;
protected override void onPartStart()
{
this.stackIcon.SetIcon( DefaultIcons.STRUT );

//Find Clips on Part Creation
allAnimations = this.FindModelAnimators();
clipNames = null;

int counter = 0; //Kludge: Use of a counter because I
//cannot see the AnimationStates
//in allAnimations for simple iteration!
//Also there is no string[] GetClipNames();
//which there probably should be o_O

if( allAnimations != null )
{

clipNames = new string[allAnimations[0].GetClipCount()];

foreach( AnimationState animState in allAnimations[0] )
{
clipNames[counter] = animState.name;
counter += 1;
}
}
else
print( '\nNone Found\n' );



base.onPartStart();
}

then select and play...



protected override bool onPartActivate()
{

if( allAnimations != null && allAnimations.Length > 0 )
{
//allAnimations[0].Play(clipNames[0]); //<-- 'Deploy'
//or
allAnimations[0].Play(clipNames[1]); //<-- 'Retract'

//you probably want some error checking here, but I don\'t
}

return base.onPartActivate();
}

I still can\'t get my bomb to move with it, so if anyone has any tips, that\'d be awesome.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...