- Home /
Referncing variables such as OnTriggerEnter(Collider other) thumb rule?
Hello
I want to understand this, not the collider enter (this one is nothing) but other functions. aspecially my problem is when I call the function form another function. Two examples Good idea:
...
ChangeSprite(item.spriteNeutral, item.spriteHighlighted)
}
private Void ChangeSprite (Sprite neutral, Sprite highlight)
{
//something here...
}
Bad Idea:
private void SetCollidingObject(Collider col)
{
if (m_collisionEnabled)
{
m_collisionEnabled = false;
StartCoroutine(EnableCollision(collider col));
}
}
IEnumarator(Collider col) //I want to be able to use the col var. in here
{
if (col.gameObject.tag == "Item")
{
//something here...
}
}
What are the thumb rules for referencing inside the brackets of the function?
Comment
Best Answer
Answer by tanoshimi · Jul 12, 2017 at 09:37 AM
Line 6 should read:
StartCoroutine(EnableCollision(col));
You don't declare the variable type when calling the method - only when declaring it.
Your answer
Follow this Question
Related Questions
How do I make a list of references to a variable? 2 Answers
Changing class data with a reference? 2 Answers
Can I pass a variable to a function to be assigned in c# 2 Answers
Problem with accessing static variables 1 Answer
Multiple Cars not working 1 Answer