Hey guys, I kinda have a very confusing problem here.
I use following script for experiment purposes:
var objectPrefab : Transform;
function Update()
{
var count = Input.touchCount;
for (i=0;i<count;i++)
{
var touch : Touch = Input.GetTouch(i);
if (touch.phase == TouchPhase.Began) {
var testObject = Instantiate (objectPrefab, transform.position, Quaternion.identity);
testObject.rigidbody.AddForce (transform.forward *2000);
}
}
}
The script is attached to the camera, co u can shoot objects from the camera if you touch the screen. And in the Unityplayer, with unity remote it works like a charm. But when I try to build it I get:
Assets/Scripts/Joystick 1.js(13,31): BCE0019: 'rigidbody' is not a member of 'UnityEngine.Object'.
and
Error building Player because scripts had compiler errors UnityEditor.HostView:OnGUI()
Why does it work in the player, but doesnt build itself? When I click on the error he shows me the "testObject.rigidbody.AddForce (transform.forward *2000);" Line.