forked from KumaarBalbir/3D-motion-capture---python-unity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimationCode.cs
42 lines (34 loc) · 1008 Bytes
/
AnimationCode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using System.Threading;
public class AnimationCode : MonoBehaviour
{
public GameObject[] Body;
List<string> lines;
int counter = 0;
// Start is called before the first frame update
void Start()
{
lines = System.IO.File.ReadLines("Assets/AnimationText.txt").ToList();
}
// Update is called once per frame
void Update()
{
string[] points = lines[counter].Split(',');
for(int i=0;i<33;i++)
{
float x = float.Parse(points[0 + (i * 3)]) / 100;
float y = float.Parse(points[1 + (i * 3)]) / 100;
float z = float.Parse(points[2 + (i * 3)]) / 100;
Body[i].transform.localPosition = new Vector3(x, y, z);
}
counter += 1;
if (counter==lines.Count)
{
counter = 0;
}
Thread.Sleep(30);
}
}