- Home /
rigidbody' is not a member of 'UnityEngine.Object
I have this script:
public var snowballPrefab : Transform; public var snowballSpeed : float = 6000;
function Update(){ if(Input.touchCount > 2) { if(!snowballPrefab || !snowballSpeed) { Debug.Log("[Shoot] 'bulletPrefab' or 'bulletSpeed' is undefined"); }else{ var snowballCreate = Instantiate(snowballPrefab, GameObject.Find("spawnPoint").transform.position, Quaternion.identity); snowballCreate.rigidbody.AddForce(transform.forward * snowballSpeed); } } }
Im using unity 3 for iphone devolopment and it works in the window, but it wont build.
i get this error: 'rigidbody' is not a member of 'UnityEngine.Object'.
what have I done wrong and how can it be fixed?
Thanks!
Again, please format your code. There is a little button with a graphic on it that displays "101010" over two lines. Highlight your code and then click it.
Answer by Jessy · Jan 28, 2011 at 06:40 AM
var snowballCreate = Instantiate(snowballPrefab, GameObject.Find("spawnPoint").transform.position, Quaternion.identity) as GameObject;
Also, use #pragma strict at the top of your JS scripts, and then you won't have the not-building problem.
Your answer

Follow this Question
Related Questions
Simple AddForce Scirpt help 1 Answer
rigidbody' is not a member of 'UnityEngine.Object ? 4 Answers
Modifying components of an array 1 Answer
Error in script 1 Answer
make bullet move forward. 2 Answers