I am using a variable from another script (facingRight). I get the error NullReferenceException, and I cant figure out what exactly I need to reference.
public class BulletTrail : MonoBehaviour {
public int moveSpeed = 0;
private PlayerController playerController;
void Awake()
{
playerController = transform.root.GetComponent<PlayerController>();
}
void Update()
{
if (!playerController.facingRight)
{
transform.Translate(Vector3.left * Time.deltaTime * moveSpeed);
Destroy(gameObject, 1);
}
if (playerController.facingRight)
{
transform.Translate(Vector3.right * Time.deltaTime * moveSpeed);
Destroy(gameObject, 1);
}
}
}
Yes I know that it cant be possible. public bool StartTemp; if(StartTemp) { public InputField iField; public GameObject Template; } But I need editor script to drag GameObject and InputField in inspector if and only if bool is true. If bool is false then dont show that two field in inspector. @Landern
ā SaurabhStudio