This is probably a very “noob” question…but I am attempting to call a variable from another C# file and am having difficulty. I will provide my code…
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UserVitalStats : MonoBehaviour
{
CharacterController charController;
FPCharacterController playerController; //THIS IS WHERE I CANT GET IT TO WORK
void Start()
{
charController = GetComponent < CharacterController> ();
playerController = GetComponent<FPCharacterController>(); //ALSO WHERE I CANT GET IT TO WORK
}
CALLING FROM
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FPCharacterController : MonoBehaviour
{
public Rigidbody rigidBody;
public FPCharacterController playerController;
void Start()
{
playerController = GetComponent<FPCharacterController>();
}
}
I had other code involved but just used the necessary to shorten it…if I need to I can put the full code