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

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;
    }


}
    
asked by anonymous 02.03.2017 / 16:39

1 answer

1

The error probably 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 like flashSpeed ( with uppercase "S" ). However, this attribute is defined in the class as follows:

public float flashspeed = 5f; 

That is, with the lowercase "S".

Although you (1) have not put the line where the error occurred (which, if I had less willingly, could have motivated me to just vote to close as unclear - is the tip to take more care in the future), and (2) you probably have not copied the error correctly, the error is likely to be the same # (that is, case-sensitive).

    
02.03.2017 / 17:28