Calling a function from another script
Hey guys I am working on a player control script and I'm having trouble calling functions from my other scripts, I have tried several different ways of calling functions but keep getting the error:
MissingReferenceException: The object of type 'Object' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.-
what could I possibly Be over looking?
I have tried
SomeScript script = new SomeScript();
script.MyFunction();
so how I want it to work is I have a PlayerManager Script which is attached to the character, from that I want to call functions from other scripts like a move script etc etc. the move script works fine on its own but I felt doing it this way would keep things much tidier and easier to manage.
At this stage I am trying to call the Move(); function from a separate script in the Update(); function in my Manager script and then so on so forth for damage and combat scripts etc
Have resolved the issue by doing this: First adding the move script to the player along with the manager script.
the manager script looks like this:
using UnityEngine;
using System.Collections;
public class _Player$$anonymous$$anager : $$anonymous$$onoBehaviour {
void Update ()
{
this.GetComponent<Player$$anonymous$$ove>().$$anonymous$$ove();
}
}
Your answer
Follow this Question
Related Questions
Turn on and off a Cubes(GameObject) Is Trigger. 0 Answers
Use a class like a function 1 Answer
Trying to give instantiated object a value 0 Answers
What is the recommend practice to check condition? Before calling a function or on the function? 0 Answers
The button works fine on Editor, but not on Mobile. 0 Answers