Question by
lastnoob765 · Aug 03, 2020 at 10:06 AM ·
variable
How do i access a bool(or any variable) from another script and change it??
So i have this script:
public class groundCheck : MonoBehaviour
{
public bool isColliding = false;
}
private void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "velr")
{
isColliding = true;
}else
{
isColliding = false;
}
}
And i want to access isColliding bool from movement script: so i referenced it like this
groundCheck groundC = feetCollider.GetComponent<groundCheck>();
var iscolliding = groundC.isColliding;
and now when i created function:
isCollided(bool collided)
{
if (collided)
{
velocity.y = -2;
}
}
but when i use isColliding in that method/function
isCollided(isColliding);
it says isColliding isnt something in this context
Comment
Your answer
Follow this Question
Related Questions
Assigning variables depending on other variables 1 Answer
Way of Finding/accessing a variable from another script though another variable? 1 Answer
Only plus one to variable in other script 1 Answer
Error CS1612 1 Answer
UNET - syncvars 2 Answers