I have found many suggestions using google,
on how to access the object which your script
is attached to, but common for all of them are:
They do not work! Because it involves a “:” in
the initialization, which Unity won’t accept.
My question(s) are:
1a) Could this be a product of failure,
due to the fact I use the free version?
1b) …if not, can you access an object which
the script is attached to, without using “:”?
using UnityEngine;
using System.Collections;
public class YourScript : MonoBehaviour
{
void Start(){
gameObject.transform.position=new Vector3(0.2f,0.5f,0.3f);
}
void Update(){
float x = gameObject.transform.position.x;
//do whatever you want with this x
//since we can't change x directly, we have to do a workaround
Vector3 LastPos = gameObject.transform.position;
LastPos.x=x;
gameObject.transform.position=LastPos;
}
}