Hello guys,
So I want to expose my function to another script, and I want to expose a function that has return multiple values.I want to know how to send that value to another script at the same time?
Public int sendTriggerStatus()
{
//return trigger1,trigger2,trigger3;
}
Let’s solve one problem after another. First, if you only want to return a bunch of objects of the same type, you can use an array or a list to bundle them and then return the array or list. It is not possible to return more than one object or value in .net at the same time.
The code to return three triggers at the same time may look as follows:
public int SendTriggerStatus()
{
Collider[] triggers = new Collider[3] {trigger1, trigger2, trigger3};
return triggers;
}
I want to send bool variable to other script, so i want to access the function sendTriggerStatus variables,trigger1,trigger2,and trigger3 in other script,if the variables are true then ill setactive the other gameobjects based on trigger status
Public int sendTriggerStatus()
{
//return trigger1,trigger2,trigger3;(trigger1,2,and 3 are bvariables with bool type;
}
I think I am starting to understand what your are looking for. It seems more suitable to me to split your functionality up into two different functions. The first one to calculate the trigger status:
And the second one to activate the other game object. In this code, it is supposed to be in the same script as TriggerStatus, however, this could be changed.
public void SetGameObjectActivity ()
{
bool status = TriggerStatus ();
theOtherGameObject.SetActive (status);
}
so this is my codes, actually in CheckTrigger code,I want to make a function that can pass information about trigger1,trigger2,and trigger3 values,and I want to access my trigger1,trigger2,and trigger3 variables in ActiveTheObjects code, but I don’t want to make 3 functions to return 3 values,I only want to make 1 function that pass information about each variables.I know that we can separate each of variables into a function that return each value(so there are 3 function if we want to separate the variables and I think it’s quite waste to separate each variables in different function)…so how to do this?