Hello, i have multiple instances of a script called TransformExtractor running on separate game objects, This script return transform data and mass for a object it is attached to. I need to write the Transform data and Mass to a text file off all instances of the script running and assign each one a key ( starting at 1 ?). What is the simplest way of going about this?
Thanks in advance, Bob
`using UnityEngine;
using System.Collections;
using System.IO;
public class TransformExtractor : MonoBehaviour
{
public GameObject player;
public float x;
public float y;
public float z;
public float Qx;
public float Qy;
public float Qz;
public float Qw;
public float scaleX;
public float scaleY;
public float scaleZ;
public float Mass;
// Use this for initialization
void Update ()
{
player = this.gameObject;
x = player.transform.position.x;
y = player.transform.position.y;
z = player.transform.position.z;
Qx = player.transform.rotation.x;
Qy = player.transform.rotation.y;
Qz = player.transform.rotation.z;
Qw = player.transform.rotation.w;
scaleX = player.transform.localScale.x;
scaleY = player.transform.localScale.y;
scaleZ = player.transform.localScale.z;
}
}`
This is what i have so far, but it return nothing, when the button i made in the editor is pressed. From the Debug.Log, the function is being called but the Length of transformExtractor is 0.
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
public class KS_ObjectInfoGetter : MonoBehaviour
{
public TransformExtractor[] transformExtractors;
public void KSprint ()
{
Debug.Log ("KSprint Called");
Debug.Log (transformExtractors.Length);
transformExtractors = GetComponents<TransformExtractor> ();
int i;
for(i = 1; i < transformExtractors.Length ; i++)
{
Debug.Log(i.ToString () + "," +
transformExtractors *.x.ToString () + "," +*
_ transformExtractors .y.ToString () + “,” +_
_ transformExtractors .z.ToString () + “,” +
transformExtractors .Qx.ToString () + “,” +
transformExtractors .Qy.ToString () + “,” +
transformExtractors .Qz.ToString () + “,” +
transformExtractors .scaleX.ToString () + “,” +
transformExtractors .scaleY.ToString () + “,” +
transformExtractors .scaleZ.ToString () + “,” +
transformExtractors .Mass.ToString () + “,”_
* );*
* }*
* }*
}