So I’ve been making a 2d platformer game in Unity (c#) and I have a variable in my playerMovement script called “isDashing”, that I want to access in my healthManager script, so that the player would only take damage if the player isn’t dashing. Also both Scripts are on the same GameObject.
Code Snippet from playerMovement:
public class Move : MonoBehaviour
{
private bool isDashing;
....
}
Code Snippet from healthManager:
public class health : MonoBehaviour
{
private bool isDashing;
void Awake()
{
isDashing = GameObject.FindObjectOfType<Move>().GetComponent<Move>().isDashing;
}
The code didn’t return any errors, but it doesn’t do anything. I’ve already tried out th solutions of other posts, but no luck. I have just started using Unity so i would really apreciate your help.
Thanks in advance.