Create GameObjects and move them from JSON data
Hello,
Consider this data:
[
{
PartId: 0,
Positions: [
{ x: 0, y: 0, z: 0, timeCode: 0.0000 },
{ x: 0, y: 0, z: 1, timeCode: 0.0025 },
{ x: 0, y: 0, z: 2, timeCode: 0.0050 },
{ x: 0, y: 0, z: 3, timeCode: 0.0075 },
{ x: 0, y: 0, z: 4, timeCode: 0.0100 },
{ x: 0, y: 0, z: 5, timeCode: 0.0125 },
{ x: 0, y: 0, z: 6, timeCode: 0.0150 },
{ x: 0, y: 0, z: 7, timeCode: 0.0175 },
{ x: 0, y: 0, z: 8, timeCode: 0.0200 },
]
},
{
PartId: 1,
Positions: [
{ x: 0, y: 0, z: 0, timeCode: 0.0000 },
{ x: 0, y: 0, z: 2, timeCode: 0.0025 },
{ x: 0, y: 0, z: 4, timeCode: 0.0050 },
{ x: 0, y: 0, z: 6, timeCode: 0.0075 },
{ x: 0, y: 0, z: 8, timeCode: 0.0100 },
{ x: 0, y: 0, z: 10, timeCode: 0.0125 },
{ x: 0, y: 0, z: 12, timeCode: 0.0150 },
{ x: 0, y: 0, z: 14, timeCode: 0.0175 },
{ x: 0, y: 0, z: 16, timeCode: 0.0200 },
]
}
]
I've loaded the JSON data and I would like to create new GameObjects (spheres) for each PartId and position/move them together through FixedUpdate. Since the timeCode is the same, I figured I could set Time.fixedDeltaTime = 0.0025f and step through the position list? What would be the best practice for something like this?
I couldn't find help for moving many objects together from a list of positions, so forgive me if this is a duplicate. Any help is much appreciated!
Your answer
Follow this Question
Related Questions
How to make gameobject appear in center of camera irrespective of it's side?? 0 Answers
Resources used by inactive Game Objects, many weapons 0 Answers
Can I snap a game object to the face of another similar to vertex snapping? 2 Answers
Positioning a prefab correctly with Instantiate 3 Answers
Dynamic sorting objects on terrain 0 Answers