Answer the question
In order to leave comments, you need to log in
What should I do to make the code work?
Created a script in a unit, entered the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
public Transform SelfTransform;
void Update()
{
SelfTransform.Translate(0.1f, 0, 0);
}
}
attached to the character and get this error:
UnassignedReferenceException: The variable SelfTransform of NewBehaviourScript has not been assigned.
You probably need to assign the SelfTransform variable of the NewBehaviourScript script in the inspector.
UnityEngine.Transform.get_position() <0x38fe2290 + 0x0006a> in <6a3f68e4ae18416e9941eafa34caba8a>:0
UnityEngine.Transform.Translate (UnityEngine.Vector3 translation, UnityEngine.Space relativeTo) (at C:/buildslave/unity/build/Runtime/Transform/ScriptBindings/Transform.bindings.cs:118)
UnityEngine.Transform.Translate (System.Single x, System.Single y, System.Single z) (at C:/buildslave/unity/build/Runtime/Transform/ScriptBindings/Transform.bindings.cs:134)
NewBehaviourScript.Update () (at Assets/NewBehaviourScript.cs: 10)
What can I do to make it work?
Answer the question
In order to leave comments, you need to log in
The variable SelfTransform of NewBehaviourScript has not been assigned.
You probably need to assign the SelfTransform variable of the NewBehaviourScript script in the inspector
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question