Jump to content

How to create a simple animated part in Unity 5.4? (not Blender)


Recommended Posts

Say, there is a simple cube which represents an antenna. Normal state - "retracted", scaled and/or moved up - "extended".
Another simple cube - the antenna base, unchangeable.

Basically, I understand that there are "animations" in Unity, they have nodes. We select a node, select an object and set its position, rotation, scale for the animation phase.
This worked in Unity player.
Then we export this animation inside the mu file of the part and add a corresponding animation module in cfg (say, taking a stock antenna as an example).
I did this but still can't see this working in KSP.

There are several tutorials on this forum and on youtube, but the problem is that all of them are either "how to export an animation from Blender to Unity", or "animation in Unity 3.x or 4.x".
I'm just a casual user of Unity editor, so I don't know the mechanism very well, and 4.x interface looks very different for me, so probably I miss something.

Please, is it possible to give a step--by-step sequence of this?

1. Given a Unity 5.4 project with a simple antenna part. As a static part it successfully gets exported and works.
2. In this part's GameObject we have two cubes (or at least just one for simplicity). Doesn't matter, imported or just created in Unity. But no animations, no FBX, etc.
3. Which steps should we click to make one cube to have two positions: "antenna retracted" / "antenna extended"? Without Blender, just Unity.
4. .. . and to correctly export it to mu file, so this would work in KSP.

Edited by kerbiloid
Link to comment
Share on other sites

8 hours ago, kerbiloid said:

...

Please, is it possible to give a step--by-step sequence of this?

1. Given a Unity 5.4 project with a simple antenna part. As a static part it successfully gets exported and works.
2. In this part's GameObject we have two cubes (or at least just one for simplicity). Doesn't matter, imported or just created in Unity. But no animations, no FBX, etc.
3. Which steps should we click to make one cube to have two positions: "antenna retracted" / "antenna extended"? Without Blender, just Unity.
4. .. . and to correctly export it to mu file, so this would work in KSP.

Step-by-step unity only sequence for 2 cubes with moving animation:

Creating an empty GameObject and the two cubes is self-explaining I think. Make sure GameObject is at 0,0,0 and has the parttools-component.

Select the GameObject (1) and hit "Add Component"(2). Under Miscellaneous click on "Animation"(3) (not AnimatoR!). This way the animation component
is located at the GameObject.

Spoiler

B7qowum.png

Open the Animation window. Ctrl + 6 or Window/Animation.

Spoiler

FuM4AYF.png

Create a new Animation, in this case "TestAnimation".

Spoiler

SF4Ybb9.png

In the top left (1) you can switch between different animations if you want to have multiple. Switch to curve-view (2) and hit "Add Property"(3). Navigate down to the transformation of the mesh you want to move and add "Position"(4).

Spoiler

wx0eioM.png

Go to frame 60 (1) and change the value of the Y coordinate from 0 to 1 (2).

Spoiler

njMsLht.png

That's it. Close the animation window, export the model and all you need is a config:

PART
{
	// General parameters
	name = TestAnim
	module = Part
	author = A

	// Asset parameters
	mesh = model.mu
	scale = 1
	rescaleFactor = 1

	// Node definitions - Position X, Position Y, Position Z, Up X, Up Y, Up Z
	node_stack_top = 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 2
	node_stack_bottom = 0.0, -0.5, 0.0, 0.0, -1.0, 0.0, 2

	// Editor parameters
	TechRequired = experimentalElectrics
	entryCost = 10
	cost = 10
	category = Utility
	subcategory = 0
	title = TestAnim
	manufacturer = A
	description = 

	// attachment rules: stack, srfAttach, allowStack, allowSrfAttach, allowCollision
	attachRules = 1,1,1,0,0

	// Standard part parameters
	mass = 1.85
	fuelCrossFeed = True
	bulkheadProfiles = size2, srf

	// Drag
	dragModelType = default
	maximum_drag = 0.2
	minimum_drag = 0.2
	angularDrag = 2

	// Damage and Temperature
	crashTolerance = 10
	maxTemp = 1400

	// Modules
	MODULE
	{
		name = ModuleAnimateGeneric
		animationName = TestAnimation
		actionAvailable = true
		actionGUIName = Toggle Cube
		startEventGUIName = Deploy Cube
		endEventGUIName = Retract Cube
		eventAvailableEditor = true
		eventAvailableEVA = true
		eventAvailableFlight = true
		evaDistance = 5
	}

	// Resources
}

The only important lines inside the Module are name and animationName. I've used ModuleAnimateGeneric but ModuleAnimationGroup is also valid.

Notes: The hirarchy and names of GameObjects and meshes cannot be changed after you created the animation. There are ways around that but it's easier to make the animations as last step when everything else is already set up.

(imgur album)

Hope this solves your problem :)

Link to comment
Share on other sites

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...