Why am I receiving this error in unity through this line of code?

The error and line of code are shown here;

:sad:

I can only imagine that the transform.Find(“Capsule”) did not return anything.

Hey.

if you want proper help for code problems it is better to paste the code itself and the full error message with the description in which line the error occurs.

Here is a description how to use the code tags correctly: http://forum.unity3d.com/threads/143875-Using-code-tags-properly

Otherwise we can only guess why the error occurs.

try this:

transform.Find("Capsule").Translate(0,0.02f,0);

For any value this is a decimal you need to state that it is a float, donated by the “f” after a decimel

djfunkey, pretty sure that will not work still… Maybe.

Another possible issue is that this is a cast issue as well. When using something like gameObject.Find, you have to at least store it on a temporary variable and then do anything on it. I believe this is the case for FindWithTag, and Find should be the same.

Maybe :smile: If it works, please say so!

Transform.Find only finds child transforms, meaning Capsule would have to be attatched to a child of the object this script is run on.
Try:

GameObject.Find("Capsule").transform.Translate(0,0.02f,0);

Only if you’re using C#, which the OP is not, and in any case that has nothing to do with the error.

Nope. The answer posted by shaderbytes is correct: the script is apparently not attached to the Sphere object, because otherwise it would work.

–Eric