Hello,
I’m currently having trouble using the GetComponent function to access scripts.
I currently have three scripts. One called ForcesUmbrella attached to an object in the scene,
another called CameraInfo attached to the Main Camera and the final one called GetInfo
attached to both the camera and the game object.
What I am trying to do is access the GetPosition() function in ForcesUmbrella from CameraInfo
through GetInfo but I keep getting a “NullReferenceException: Object reference not set to an instance of an object” error
so I must be doing something wrong.
If somebody can point me in the right direction I would be more than grateful.
Thank you and here are the scripts:
#### ForcesUmbrella ####
import UnityEngine
class ForcesUmbrella (MonoBehaviour):
def Start ():
pass
def Update ():
pass
def GetPosition():
Debug.Log('It works')
#####################
#### CameraInfo ####
import UnityEngine
class CameraInfo (MonoBehaviour):
public umbInfo as GetInfo
def Start ():
umbInfo = GetComponent[of GetInfo]()
def Update ():
umbInfo.GetUmbrella()
##################
#### GetInfo ####
import UnityEngine
class GetInfo (MonoBehaviour):
public umbInfo as ForcesUmbrella
def Start ():
umbInfo = GetComponent[of ForcesUmbrella]()
def Update ():
pass
def GetUmbrella():
umbInfo.GetPosition()
##############