unity anima 2d learning notes 2

15.you can set the parent bone’s child to none to detach the first child bone(this troubles me for a long time. sometimes you don’t want to have any child bone, before I just add a dummy child bone..)
16.spring manager: stiffness decide how hard to change the bone(0.001 in tutorial). drag decide how fast the bone will come back the idle position(0.4 in tutorial)
17.alt+click the hiarchy will open(or collapse)everything in this hiarchy
18.add spring manager in the character, and spring bone in each bone.
19.spring bone: radius, for collider. is use each bone force setting:use stiff&drag in manager or in each bone. spring force: idle position
20.set z order in spriteMeshEditor->inspect->z order to decide how parts in one sprite order when overlap(eg when you rotate the arm, how should forarm and rear arm orders when overlap
21.how to change face/clothes: make a new face, drag it in the scene and move to the same position of the old face, add bone and set order and everything, delete it. add “sprite mesh animation” to old face.add old face and new face’s prefab. in anim, change the frame in it.
22.same for the clothes, you can make different frames for the clothes to change them.

used spring bones(see the tail :P) and mesh anim on giraffe:

Advertisements
Posted in 未分类 | Leave a comment

unity anima2d learning notes

this is some learning notes i took from the tutorial:

1.for all sprite, create->anime 2d->mesh
2.for each mesh, edit it if you want. Shift and click an edge to add a vertice at the edge.
3.slice->apply will make a better outline
4.add vertices by double click. at place where is going to have deform
5.put all meshes under one onbject. change layer and depth in layer to show the character correctly.
6.add object bones, in it add object with Bone 2d components.(create->2d->bone will make a bone as a child of current bone). add bone on what is based on what bone rotate will change this bone rotate
7.add bone into mesh->set bones. only left bones that in the mesh. open edit mesh. bind. check overlay to see how bones effect whole mesh. check pies to see how bones effect each vertices. select bone and change weight if you want.
8.add IK limb under bone. put it near hand and add arm bone to it. it will affect 2 bones. may need flip if it look wierd. IK CCD can be used for multiple bones but might not work for leg(that’s for tails and hairs)
9.add animation.add pose manager and add a bind pose(like t pose, what is this for?). then add animator controller. then add animation clip. record and set the position of IKs, then move the hip a little down to make an idle anim. bake the anim so it will bake for all bones and all frames(for complicated anim like walk, you might want to save a pre back version of it so it’s easy to change later.)
10.we can change the gizmo size of IK on the top right conor of scene. we can create a square sprite by create->sprites->square
11.add foot IK as a child of leg IK to make foot anim works( another way is to dis select orient child on leg IK and rotate.)
12.onion skin.to show how player looks in an animation before/after current frame frames(how many frame you want to see) step(how many steps as a skin)
13.walk is hard….might need to take a course about how to make nature walk anim…
14.nature blink 3(close eyes)-2(open eyes)-7(keep opening)

15.since each part of one character is not on the same order in layer, when they overlap, some weird thing might happen. eg: mouse(which is high sort order) of B will be drawn in higher order than A’s face, which B’s face is below A:

无标题

how i solve this is kind of stupid.. i use a static value to save the zOffset and keep adding it when create a new one. this might cause a problem when create a lot characters but i’ll solve that when that happens..code looks like this:

static int zOffset;
override protected void Start () {
base.Start ();
foreach (Anima2D.SpriteMeshInstance sr in GetComponentsInChildren<Anima2D.SpriteMeshInstance>()) {
sr.sortingOrder += zOffset;
}
zOffset += 10;
currentOffset = zOffset;
}

this is the video,hamster and house used anima2d:

Posted in 未分类 | Leave a comment

learning note – procedure cave generation

 

this is cool. generate cave 0-1 map by smooth random map, then create mesh, then find the wall(edge) and draw them, then find the size of room,delete too small size room and connect rooms together.

 

notes:

1. [Range(0,100)] public int randomFillPercent;
This can create a slide in inspector to select the int value
2.int[,] map;
3.seed = Time.time.ToString(); System.Random random = new System.Random(seed.GetHashCode());
//Get psudo random value each time
//use:
Random.Next(0,100);
4.void OnDrawGizmos()
Can be used to draw some cube.
Gizmos .color = (map[x,y]==1)?Color.black:Color.white;
Gizmos.DrawCube (pos, Vector3.one);
5 int[,] map,
map.GetLength(0) map.GetLength(1) to know the length of multi dimension array.
6 align with view: align camera with view
Align view to selected: align scene view to camera
7 Mesh mesh = new Mesh ();
mesh.vertices = vertices.ToArray ();
mesh.triangles = triangles.ToArray ();
mesh.RecalculateNormals ();
GetComponent<MeshFilter> ().mesh = mesh;
This way can manually set mesh infos.
Vertices saves all the position of each vertice.
Triangles has 3*number of triangle value, each is an index, use that index can get position from vertices.
8 this way to draw mesh is interesting. Use four control node and four non-control node. If a control node is selected, its neighbour non-control node will be selected.
9 define of outline edge: two vertics which share one triange.
10 get intersect of two list
List<Triangle> trianglesContainingVertexA = triangleDictionary [vertexA];
List<Triangle> trianglesContainingVertexB = triangleDictionary [vertexB];
IEnumerable<Triangle> intersect = trianglesContainingVertexA.Intersect (trianglesContainingVertexB);
11 access a struct like an array:
struct Triangle {
public int[] vertices = new int[3];
public Triangle(params int[] v) {
for(int i = 0;i<v.Count;i++){
vertices[i] = v[i];
}
}
public int this[int i]{
get {
return vertices[i]
}
}
}
12 when set mesh filter, set vertices first, then triangle.
Triangles has to be counter clock wise
13 use queue:
Queue<Coord> queue = new Queue<Coord> ();
Coord tile = queue.Dequeue ();
queue.Enqueue (new Coord (x, y));
14 int max value: int.MaxValue
15 if not set color for drawline, it wont draw anything
Debug.DrawLine (CoordToWorldPoint (tileA), CoordToWorldPoint (tileB), Color.green, 100);
16 inherite from Icomparable and implement compareTo
public int CompareTo(Room otherRoom){
return otherRoom.roomSize.CompareTo (roomSize);
}
Then can use rooms.sort() to sort them
Notice you have to write like this:
class Room : IComparable<Room>
IComparable defines an int CompareTo(object) while the generic IComparable<T> defines an int CompareTo(T)
17 set default value for method
void ConnectClosestRooms(List<Room> allRooms, bool forceAccessibilityFromMainRoom = false)
18 generate collider:
In either one, remember to delete the former collider before add new.
MeshCollider wallCollider = walls.gameObject.GetComponent<MeshCollider> ();
Destroy (wallCollider);
3d:
Create meshCollider and set the sharedMesh as mesh in meshFilter.
wallCollider = walls.gameObject.AddComponent<MeshCollider> ();
wallCollider.sharedMesh = wallMesh;
2d:
Create edgeCollider2D and set the points as vector2.
EdgeCollider2D edgeCollider = gameObject.AddComponent<EdgeCollider2D> ();
Vector2[] edgePoints = new Vector2[outline.Count];
for (int i = 0; i < outline.Count; i++) {
edgePoints [i] = new Vector2( vertices [outline [i]].x,vertices [outline [i]].z);
}
edgeCollider.points = edgePoints;

Posted in 未分类 | Leave a comment

learning note – maya, make a lemon

 

learning note:

1 Select vertex and move them

2 Select->shift +right ->smooth

3 Right ->assign material->labert

4 Create bump image:

window->renderer editors->hypershade

Select the labert

Bump/normal mapping, select fractal

Go back to model, press 6

5 cut lemon:

Right click->face

Select half of lemon

Edit mesh->extract

Move that half away

Select half, mesh->fill hole

6 press g to repeat last instruction

7 add texture:

Select face, assign material, color->file,select file

UV->automatic

UV->editor

8 animation:

Add fx->nCloth->passive soft body to ground

Add active soft body to lemon. Add fields/solvers->gravity to lemon

Change frame to longer.

Play

9 light click 7 to apply light

my result:

Posted in 未分类 | Leave a comment

learning photoshop

just bought a wacom and played with it. here is the tutorial:

and this is my paint..

kirby_paint.jpg

…i know some thing looks weird.. but take a look at my first try:

kirby_first.jpg

…really photoshop is so powerful to make someone like me can draw a picture like that. and wacom is harder than draw on paper, or maybe i just need to practice more…

 

what i learned:

1.use ctrl+alt and right mouse to control size and flow of the pen.

2.draw on different layers, first two for sketch, then draw faster on third one to looks like the second version but with confident, smooth line.

3.draw a circle: select a circle, fill with not all layers, layer blend->stoke, magic erase the middle of it, wrap it to looks like a circle drawed by human.

4.lock transparent pixel then draw, will only draw when this layer has stuff.

5.use merge down to merge two layers.

Posted in 未分类 | Leave a comment

roguelike 2d game learning notes

https://unity3d.com/cn/learn/tutorials/projects/2d-roguelike-tutorial/project-introduction?playlist=17150

1.drag sprites to a gameobject will create animation and animator automatically with those sprites.
2.in box collider2d, make size a little smaller so won’t collide thing in other tile
3.3d physics and 2d physicsc can exist together in one scene, but won’t interact
4.hold shift to change the collider box in collider 2d
5.sprite is a texture, it need to be set in texture type,2d project will set texture to sprite automatically. Multiple mode can mean it contain animation sheet or separate part of a unit. Pixel to unit: how many pixel calculated
6.inspector can be locked.. So when you add prefabs into a list, can select multiple and drag into the list
7.instance:
In GameManager:
public static GameManager instance = null;
In GameManager.awake:
if (instance == null) {
instance = this;
} else if (instance != this) {
Destroy (gameObject);
}
In Loader:
if (GameManager.instance == null) {
Instantiate (gameManager);
}
Then we only need Loader script in game
8.in animation transition, settings, can set transition duration as 0 since for 2d sprite there is no way to blend.
Set exit time to 1 so to transite when the animation is end
9.[HideInInspector] for public variable that can’t be seen in editor
10.The Serializable attribute lets you embed a class with sub properties in the inspector. The class should be serializable:
[Serializable]
public class Count
{
public int minimum;
public int maximum;
public Count (int min, int max)
{
minimum = min;
maximum = max;
}
}
Now when you wirte public Count enemyNumber; this number will be shown in inspector
11.when inherite, the parent method should be protected virtual or protected abstract, and the child method should be protected override .
12.template:
protected abstract void OnCantMove<T> (T component)
where T:Component{}
When override, no need to say the T:
protected override void OnCantMove<T>(T component){ }
When use:
OnCantMove<Wall> (Wall wall);
13.if raycast, it might: collide with it self, can uncheck
Edit -> Project Settings -> Physcis 2D -> Raycasts Start In Colliders to avoid this.
14.Linecast, will do ray cast in a segment
15.new way to load new level:
SceneManager.LoadScene(0);
Also import:
using UnityEngine.SceneManagement;
16…. A good structure is very important. I should try to write my own game to practice this skill
17.test animation in animator controller to make sure the transition works.
18.called when a level is loaded :
void OnLevelWasLoaded(int index){
19.can drag same kind of component to different variable.
20.method(param Gameobject[] object) can parse any number objects and will treat them as an array. Just skip the step to create an array yourself.
Use: method(object1,object2..)
21.-Vector2.one = out of screen
23.when import assets from assets store, pay attention that your settings and layers and everything might be changed.. Which will cause a lot trouble…

Posted in 未分类 | Leave a comment

unity test tool learning notes

https://unity3d.com/cn/learn/tutorials/topics/production/unity-test-tools

today we had a speech about test in company. so i think, there must be some fancy test tool for unity. here is what i learned in it:

1.assertion component can be used when you want to test when something happens, you can set assertion like value>50 and open error pause in console, then when value decrease to 50, it will pause.
2.debug value with assertion component means you don’t need to add code and delete later, you don’t need to add a lot of break point if you have that value changed at a lot of places.
3.can control all assertions in assertion explorer
4.integrate test is test on another scene and test how things work together.
Need to add test and each test is separate. They have different scene
First way to test is a call test, set when to pass and when the fail.
Second way is write script, use IntegrationTest.Pass(gameObject) or fail to set the result.
Third way is add assertion on gameObject in the test, and check succeed on assertion. So as long as all assertion succeed, it pass.
The reason we need the complex integrate test is for future when things get complicated and people might mess something up, the test will help them know they might do something wrong.
5.in integrate test, the timeout means, if in this time, it’s not passed, then fail it.
6.when add integrate test, might add that on a separate gameobject so easy to find out.
7.unit test is for code specifically.
8.add unit test is in asset/create/editor test, and see all unit tests are in window/editor test
9.use assert… to pass/fail a unit test.

Posted in 未分类 | Leave a comment