call a function unity code example

Example 1: call function from another script unity

void Start()
{
    ClickToMove = FindObjectOfType<ClickToMoveScript>();
    ClickToMove.PlayWoodCuttingAnim();  
}

Example 2: how to make a function unity c#

Void Start()
{
  //call a void function (will return nothing/null)
  MyVoidFunction(false);
  debug.log(MyIntFunction(7));
}

Void MyVoidFunction(bool n)
{
  if(n)
  debug.log("Void Function Ran, n is true")
  if(!n)
  debug.log("Void Function Ran, n is false")
  //if you get an error here do
  //return;
}
int MyIntFunction(float x)
{
 return x * 2; 
}