Assets\Scripts\HealthController.cs(22,49): error CS1003: Syntax error, ',' expected

pls help me with this error
Assets\Scripts\HealthController.cs(22,49): error CS1003: Syntax error, ‘,’ expected

code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class HealthController : MonoBehaviour
{
[Header(“Player Health Amount”)]
public float currentPlayerHealth = 100.0f;
[SerializeField] private float maxPlayerHealth = 100.0f;
[SerializeField] private int regenRate = 1;
private bool canRegen = false;

[Header(“Add the Splater image here”)]
[SerializeField] private Image redSplatterImage = null;

[Header(“Hurt Image Flash”)]
[SerializeField] private Image hurtImage = null;
[SerializeField] private float hurtTimer = 0.1f;

[Header(“Heal Timer”)]
[SerializeField] private float healCooldown 3.0f;
[SerializeField] private float maxHealCooldown = 3.0f;
[SerializeField] private bool startCooldown = false;

[Header(“Audio Name”)]
[SerializeField] private AudioClip hurtAudio = null;
private AudioSource healthAudioSource;

private void Start()
{
healthAudioSource = GetComponent();
}

void UpdateHealth()
{
Color splatterAlpha = redSplatterImage.color;
splatterAlpha.a = 1 - (currentPlayerHealth / maxPlayerHealth);
redSplatterImage.color = splatterAlpha;
}

IEnumerator HurtFlash()
{
hurtImage.enabled = true;
healthAudioSource.PlayOneShot(hurtAudio);
yield return new WaitForSeconds(hurtTimer);
hurtImage.enabled = false;
}

public void TakeDamage()
{
if(currentPlayerHealth >= 0)
{
canRegen = false;
StartCoroutine(HurtFlash());
UpdateHealth();
healCooldown = maxHealCooldown;
startCooldown = true;
}
}

private void Update()
{
if(startCooldown)
{
healCooldown -= Time.deltaTime;
if(healCooldown <= 0)
{
canRegen = true;
startCooldown = false;
}
}

if(canRegen)
{
if (currentPlayerHealth <= maxPlayerHealth - 0.01)
{
currentPlayerHealth += Time.deltaTime * regenRate;
UpdateHealth();
}
else
{
currentPlayerHealth = maxPlayerHealth;
healCooldown = maxHealCooldown;
canRegen = false;
}
}
}
}

Please edit your post to use code-tags when posting code and not plain text.

The error tells you the line (22) and column numbers (49) so you only have to look there to see why it’s expecting a comma.

Around that area you’ll have a typo so just look at the code carefully or compare it to where you’re copying the code from.

The compiler might expect something but it’s nearly always because you made it expect that as you made a typo so look at the area but don’t take what the compiler expects as what’s wrong.

1 Like