CS00103 The name 'flashspeed' does not exist in the Current context

Asked

Viewed 53 times

0

This error message appears, what should I do?

using UnityEngine;
using UnityEngine.UI;      //
using System.Collections;


public class PlayerHealth : MonoBehaviour
{
    public int startingHealth = 100;
    public int currentHealth; //qundo tomar dano valor cai
    public Slider healthSlider; //barra de vida
    public Image damageImage; //DamageImage
    public AudioClip deathClip; //audio quando morre
    public float flashspeed = 5f; //velocidade quando DamageImage pisca apagar para continuar vendo o jogo
    public Color flashColour = new Color(1f, 0f, 0f, 0.1f); //cor da damageimage red gree blue alfa (transparente)


    Animator anim; //puxar animação
    AudioSource playerAudio; //vincular audio
    PlayerMovement playerMovement; //sript playermovement (habilitar e desabilitar)
    //PlayerShooting playerShooting;
    bool isDead;
    bool damaged;


    void Awake ()  //pegando os componentes
    {
        anim = GetComponent <Animator> (); 
        playerAudio = GetComponent <AudioSource> ();
        playerMovement = GetComponent <PlayerMovement> ();
        //playerShooting = GetComponentInChildren <PlayerShooting> ();
        currentHealth = startingHealth; 
    }


    void Update ()
    {
        if(damaged)
        {
            damageImage.color = flashColour;
        }
        else
        {
            damageImage.color = Color.Lerp (damageImage.color, Color.clear, flashSpeed * Time.deltaTime);
        }
        damaged = false;
    }


    public void TakeDamage (int amount) //para ser chamado em outro script - o quanto de dano player tomou
    {
        damaged = true;

        currentHealth -= amount;

        healthSlider.value = currentHealth;

        playerAudio.Play ();

        if(currentHealth <= 0 && !isDead)
        {
            Death ();
        }
    }


    void Death ()
    {
        isDead = true;

        //playerShooting.DisableEffects ();

        anim.SetTrigger ("Die");

        playerAudio.clip = deathClip;
        playerAudio.Play ();

        playerMovement.enabled = false;
        //playerShooting.enabled = false;
    }


}

1 answer

1


Probably the error occurs on this line:

damageImage.color = Color.Lerp (damageImage.color, Color.clear, flashSpeed * Time.deltaTime);

You will notice that the attribute in this line is as flashSpeed (with a capital "S"). However, this attribute is defined in the class as follows:

public float flashspeed = 5f; 

That is to say, with the tiny "S".

Although you (1) did not put the line where the error occurred (which, if I had less goodwill, could have motivated me only to vote to close as not clear - it is the tip to take more care in the future) and (2) probably have not copied the error correctly, it is quite likely that the error is the same because C# is case sensitive (that is, differentiate between upper and lower case).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.