SchultzGames
Para tirar dúvidas, crie um tópico especifico na área "Dúvidas em Geral" e aguarde ser respondido. Evite comentar em tópicos não relacionados a sua dúvida :D
TÓPICOS RECENTES:
Tópico:
Postado em:
Postado por:
WW2 Low poly Pack (Free)
Procuro freelancer
Novo Teaser do jogo Dark Age
Unity Admob Erro
Mais Um jogo!
DEATH ISLAND 0.2.5 SURVIVAL GAME 4 ANOS EM DESENVOLVIMENTO
Player travando na colisão com o chão Unity 2D
Sombras estão quadradas na build
nao consigo fazer o player sentar no sofa alguem me ajuda
Unity - Ao mudar de scene, todas as Lights são deletadas
210 Linhas de código para inimigo é muito grande?
modelar avatar e skins para um jogo web
Collider (mesh?)
ShapeKeys do Blender para a Unity altera áreas próximas
COMO EVITAR QUE UM OBJETO (PLAYER,ITEM ETC...) ATRAVESSE UMA PAREDE.
Ajuda em Script de Verificação de Ação e Reação
unity Failed to load PlayerSettings (internal index #0). Most likely data f
PRECISO FAZER QUE MEU GAME FIQUE ONLINE
Materiais do Blander não aparecem no MeshRendere do Objeto na Unity
Repetiçoes de Textura no Terreno
SERVER IS DOWN - UNITY+MSQL
Procuro programadores - Novo jogo
Problema com o MS VEHICLES
Preciso de ajuda com a Unity
Problema com vídeo em 360° na Unity
Problemas no MS Vehicles
unity- eventos na Animação com Armature/Bones vinda do blender não funciona
ajuda exibir resultados simulados em uma liga Game Unity
Unity - ParticleSystem não é redirecionado no rawimage no canvas
Como resolver o problema de "face orientation" no Blender.
[DÚVIDA] Tive um problema com meu Canvas
erro na Directional Light
Problemas com o Directional Light da Unity 3D
Novo jogo da franquia Sphere game em desenvolvimento
malha da roda não girando com wheel collider unity
Problemas com ambiguidade
Touch mobile
INVALID TOKEN
Como acessar o "HD Render Pipeline" do HDRP por script?
CHAT GPT PRA JOGO DE TIRO? comentem
Tutorial script inimigo segue e foge do player
Ainda vale a pena lançar Asset na Asset Store?
Ajuda com tabela de historico de pontuaçao.
[TUTORIAL] Entrar no carro estilo GTA
Como derrapar um Whell Collider
Como altertar o valor do "Asymptote Value" do Whell Collider via Script
Preciso de ajuda para substituir valor de variavel em outro script
Ajuda com Top Down Shooter utilizando Photon
Duvida com Netcode
[RESOLVIDO] Unity - Movendo a Câmera na Horizontal/Vertical com Touch
Alguém me ajuda com os anúncios pfv
Segundo Trailer do jogo Dark Age, Feliz Natal a todos!
Unity - ScrollRect, Viewport, Content - O Conteúdo ñ inicia no topo
Coleta de itens
Unity - Cadastro do email do jogador
[GRATIS] PACK DE MODELOS 3D PARA JOGO DE TERROR
Onde Conseguir músicas para meu Jogo?
error CS0246 em Script
Alguem teve ja esse problema?
[Projeto em Andamento] Draug, um jogo de hordas
DISPONIVEL PARA FAZER MODELOS 3D
Unity-Loja.Como os Jogadores terão acesso aos ítens comprados na PlayStore?
Bugando depois do Build.
Primeiro Trailer do jogo Dark Age
Problema com sombra
Mesh e Material do objeto trocando para uma instancia no inicio do jogo
[RESOLVIDO] Unity - RawImages_Layer_Camera
INVESTIMENTO EM JOGOS E BANCO DE TALENTO
Teaser do meu novo projeto pessoal, Dark Age
Preciso de ajuda com mudança para mobile androide.
[RESOLVIDO] Posição final do objeto em jogo 2D
Input.GetAxis() obedercer a orientação de um objeto.
Interação com elementos UI
Meu primeiro jogo na steam
Minimap/Radar/GPS Estilo GTA V
[RESOLVIDO] Erro no console depois que formatei o pc
PACK GRÁTIS de Músicas ELETRÔNICAS para ajudar vocês em seus Jogos Indies!
[TUTORIAL] Entenda como funciona: ENUM, SWITCH, BREAK, CASE no C#
O Labirinto II - Baixe o Jogo
Qual e o codigo de Botões na unity para saber seus estados?
Como carregar itens pequenos dentro do carro sem que atravesse os colliders
[Duvida] Script pegar itens
Travamento ao trocar de cena
Colisão zoada e movimentação
Salvar objetos que foram destruidos entre cenas na unity
Quero começa a desenvolver um jogo de luta porem eu queria aprender a faze
Pegar qual objeto colidiu com o Linecast.
movimentação e camera?
[RESOLVIDO] Unity - SceneManager.LoadScene abre scene com objeto "vazio"
[RESOLVIDO] ajuda sobre skybox
MEU SIMULADOR DE CARRO
[_____IMPORTANTE_____] ALTERAÇÕES NA POLÍTICA DE COBRANÇA DA UNITY
[RESOLVIDO] Ausencia da funçao NavMesh na Unity 2022.2.12
[_____IMPORTANTE_____] ALTERAÇÕES NA POLÍTICA DE COBRANÇA DA UNITY - 2
Roll Up Um jogo de aventura e desáfios
Terminologia da Unity em outras engines
Como criar a iluminação do Sol no Sistema Solar?
Conexão de lobby pelo OnConnectedToMaster
Problema na exportção de projeto unity
Seg Abr 29, 2024 9:34 pm
Qui Abr 25, 2024 3:34 pm
Seg Abr 22, 2024 5:15 pm
Seg Abr 15, 2024 12:23 pm
Sáb Abr 13, 2024 11:37 am
Qua Abr 10, 2024 1:33 am
Ter Abr 09, 2024 10:28 am
Seg Abr 08, 2024 9:27 pm
Seg Abr 08, 2024 8:01 am
Sáb Abr 06, 2024 8:05 pm
Qui Abr 04, 2024 11:34 pm
Qui Abr 04, 2024 11:13 pm
Qui Abr 04, 2024 11:10 pm
Sex Mar 22, 2024 2:41 pm
Dom Mar 10, 2024 2:30 pm
Sex Mar 01, 2024 1:27 pm
Qui Fev 22, 2024 9:57 pm
Ter Fev 20, 2024 9:28 am
Ter Fev 20, 2024 12:15 am
Seg Fev 19, 2024 1:06 pm
Seg Fev 12, 2024 1:56 pm
Seg Fev 12, 2024 1:17 pm
Dom Fev 11, 2024 8:55 pm
Dom Fev 11, 2024 11:16 am
Seg Fev 05, 2024 4:18 pm
Dom Fev 04, 2024 9:39 pm
Qua Jan 31, 2024 11:59 pm
Ter Jan 30, 2024 7:37 pm
Ter Jan 23, 2024 6:33 pm
Dom Jan 21, 2024 6:03 pm
Sáb Jan 20, 2024 7:03 pm
Sáb Jan 20, 2024 6:58 pm
Sáb Jan 20, 2024 6:39 pm
Sex Jan 19, 2024 8:40 am
Dom Jan 14, 2024 5:30 pm
Qua Jan 10, 2024 10:29 pm
Qua Jan 10, 2024 8:55 pm
Qua Jan 10, 2024 7:14 pm
Ter Jan 09, 2024 3:55 pm
Ter Jan 09, 2024 8:04 am
Sáb Jan 06, 2024 8:02 pm
Sex Jan 05, 2024 7:01 am
Sex Jan 05, 2024 12:12 am
Qui Jan 04, 2024 6:55 pm
Qui Jan 04, 2024 12:52 pm
Qui Jan 04, 2024 4:34 am
Ter Jan 02, 2024 11:48 pm
Dom Dez 31, 2023 7:25 pm
Qua Dez 27, 2023 5:44 pm
Qua Dez 27, 2023 3:08 pm
Sáb Dez 23, 2023 7:27 pm
Sáb Dez 23, 2023 5:06 pm
Qui Dez 21, 2023 8:10 pm
Seg Dez 18, 2023 2:04 pm
Sex Dez 15, 2023 5:11 pm
Qui Dez 14, 2023 9:13 pm
Qui Dez 14, 2023 2:47 pm
Qui Dez 14, 2023 1:48 pm
Qua Dez 13, 2023 8:58 pm
Ter Dez 12, 2023 2:32 pm
Seg Dez 11, 2023 1:53 pm
Qua Dez 06, 2023 8:13 pm
Sáb Dez 02, 2023 8:06 pm
Qui Nov 30, 2023 7:49 am
Seg Nov 27, 2023 1:35 am
Qua Nov 22, 2023 7:37 am
Qui Nov 09, 2023 1:22 pm
Seg Nov 06, 2023 11:59 am
Ter Out 31, 2023 9:53 am
Dom Out 29, 2023 8:05 pm
Dom Out 29, 2023 3:03 am
Sex Out 27, 2023 3:43 pm
Sex Out 27, 2023 3:28 pm
Qua Out 25, 2023 1:20 pm
Seg Out 23, 2023 10:34 am
Dom Out 22, 2023 6:55 pm
Qui Out 19, 2023 11:57 pm
Qui Out 19, 2023 6:39 pm
Ter Out 17, 2023 6:37 pm
Ter Out 17, 2023 6:18 pm
Seg Out 16, 2023 1:59 pm
Sáb Out 14, 2023 12:15 pm
Qua Out 11, 2023 6:07 pm
Seg Out 09, 2023 4:19 pm
Qua Out 04, 2023 12:12 pm
Qua Out 04, 2023 12:11 pm
Ter Out 03, 2023 9:18 pm
Ter Out 03, 2023 9:08 pm
Ter Out 03, 2023 6:05 pm
Ter Set 26, 2023 12:45 pm
Seg Set 25, 2023 9:02 pm
Seg Set 25, 2023 9:47 am
Sáb Set 23, 2023 2:10 pm
Sex Set 22, 2023 9:01 pm
Qui Set 21, 2023 11:04 am
Qua Set 20, 2023 4:40 pm
Qua Set 20, 2023 9:15 am
Dom Set 17, 2023 12:17 pm
Sex Set 15, 2023 7:24 pm



































































































[RESOLVIDO] Score ao matar inimigo

5 participantes

Ir para baixo

Resolvido [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Ter maio 09, 2017 7:23 pm

OLA PESSOAL EU QUERIA UM SCRIPT PARA DA SCORE AO MATAR O INIMIGO 10 SCORE QUE APERECIRIA NA TELA ATRAVES DE UMA IMAGE UI 


AGRADEÇO DESDE JÁ!


Última edição por MarcosSchultz em Ter maio 16, 2017 5:40 pm, editado 2 vez(es) (Motivo da edição : Resolvido)
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por rafaelllsd Ter maio 09, 2017 7:27 pm

3 - O fórum é para resolução de dúvidas, portanto, venham com dúvidas. Pedir scripts prontos ou resoluções milagrosas sem querer aprender, apenas levará o usuário a ser ignorado posteriormente.


Você já tem algo pronto?
rafaelllsd
rafaelllsd
ProgramadorMaster

Masculino PONTOS : 5037
REPUTAÇÃO : 507
Idade : 23
Áreas de atuação : Unity, Audacity, Blender, Gimp, C#, JS, MySQL.

Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por marcos4503 Ter maio 09, 2017 7:33 pm

Amigo.. Eu não posso fazer scripts agora porque to num projeto aqui.. Mais só uma dica.. Tenta aprender a fazer sozinho.. Você vai agregar mais sabe? Quando mais voce tenta, mais independente você fica e ganha 10x mais experiencia com isso. Tipo.. Tenta bolar uma lógica sabe? De quando o inimigo chegar a 0 de vida, ele adiciona 10 pontos, e em seguida ele se destroy,, tipo isso..
marcos4503
marcos4503
Instrutor

Masculino PONTOS : 4862
REPUTAÇÃO : 578
Idade : 25
Áreas de atuação :
Programação, Mobile, Web e Design.

Veja meus assets para Unity!
https://windsoft.xyz/mtassets


Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

http://windsoft.xyz

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Matrirxp Ter maio 09, 2017 9:31 pm

Player Script:


Código:
 //Tiro
 public GameObject bala;
 public float velocidade;
 public Transform arma;
 Rigidbody rbbala;

 Bala ba; //SCRIPT BALA
 
GameObject My;//Player atual

public float Score;

void Start(){

My = gameObject;//Nao sei se isso ta certo

}

void Update(){

if(Input.GetKey(KeyCode.Mouse0)){ //ATIRAR APERTANDO O BOTÃO DO MOUSE

clone = Instantiate(bala,arma.position,arma.rotation) as GameObject;
ba = clone.GetComponent<Bala>();//PEGAR "BALA" SCRIPT
ba.player = My;
 rbbala = clone.GetComponent<Rigidbody> ();
 rbbala.AddRelativeForce(Vector3.forward * velocidade);

}


}





Bala Script:


Código:
public GameObject player;

void Update(){

}




Inimigo script:


Código:
Bala ba;
GameObject player;
Player pla;

void Update(){

}

void OnCollisionEnter(Collision col){

if(col.tag == "bala"){  //SE O OBJETO TIVER A TAG BALA

ba = col.GetComponent<Bala>();//PEGAR "BALA" SCRIPT

player = GameObject.Find(ba.player.name);
pla = player.GetComponent<Player>();//PEGAR "PLAYER" SCRIPT

pla.Score += 10;

}

}


Não testei mas deve funcionar!!!
Matrirxp
Matrirxp
ProgramadorMaster

Masculino PONTOS : 3187
REPUTAÇÃO : 86
Idade : 21
Áreas de atuação : Programação: C#, Java, HLSL, CG, GLSL.
Modelagem 3D.
Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

https://www.youtube.com/channel/UCkngjEDMx9y_vW0t7Io05gg

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Qua maio 10, 2017 3:12 pm

Script do Inimigo
Código:
using UnityEngine;

public class EnemyHealth : MonoBehaviour
{
    public int startingHealth = 100;
    public int currentHealth;
    public float sinkSpeed = 2.5f;
    public int scoreValue = 10;
    public AudioClip deathClip;


    Animator anim;
    AudioSource enemyAudio;
    ParticleSystem hitParticles;
    CapsuleCollider capsuleCollider;
    bool isDead;
    bool isSinking;


    void Awake ()
    {
        anim = GetComponent <Animator> ();
        enemyAudio = GetComponent <AudioSource> ();
        hitParticles = GetComponentInChildren <ParticleSystem> ();
        capsuleCollider = GetComponent <CapsuleCollider> ();

        currentHealth = startingHealth;
    }


    void Update ()
    {
        if(isSinking)
        {
            transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime);
        }
    }


    public void TakeDamage (int amount, Vector3 hitPoint)
    {
        if(isDead)
            return;

        enemyAudio.Play ();

        currentHealth -= amount;
           
        hitParticles.transform.position = hitPoint;
        hitParticles.Play();

        if(currentHealth <= 0)
        {
            Death ();
        }
    }


    void Death ()
    {
        isDead = true;

        capsuleCollider.isTrigger = true;

        anim.SetTrigger ("Dead");

        enemyAudio.clip = deathClip;
        enemyAudio.Play ();
    }


    public void StartSinking ()
    {
        GetComponent <UnityEngine.AI.NavMeshAgent> ().enabled = false;
        GetComponent <Rigidbody> ().isKinematic = true;
        isSinking = true;
        ScoreManager.score += scoreValue;
        Destroy (gameObject, 2f);
    }
}

Script do Score 
Código:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

namespace CompleteProject
{
    public class ScoreManager : MonoBehaviour
    {
        public static int score;       


        Text text;                     


        void Awake ()
        {
           
            text = GetComponent <Text> ();

           
            score = 0;
        }


        void Update ()
        {
           
            text.text = "Score: " + score;
        }
    }
}

Os score nao estao aumentando nao sei porque, e nao esta dando error nenhum
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Qua maio 10, 2017 5:40 pm

Up!!
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Manawydan Qua maio 10, 2017 9:09 pm

É so fazer dentro do void Death isso:
Código:
ScoreManager.score++;
Se der erro de que não aparece o ScoreManager importe o namespace dele, colocando isso no começo do script do Enemy:
Código:
using CompleteProject;
Manawydan
Manawydan
Mestre
Mestre

PONTOS : 3464
REPUTAÇÃO : 198
Idade : 27
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://wad.ojooo.com/register.php?ref=ManawydanBr

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Qua maio 10, 2017 9:17 pm

nao foi, esta aparecendo o score na tela mais quando mato o inimigo o score nao aumenta!
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Manawydan Qua maio 10, 2017 9:28 pm

certo poste a modificação que voce fez aki e se deu algum erro poste tambem.
Manawydan
Manawydan
Mestre
Mestre

PONTOS : 3464
REPUTAÇÃO : 198
Idade : 27
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://wad.ojooo.com/register.php?ref=ManawydanBr

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Qua maio 10, 2017 9:31 pm

Código:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.SceneManagement;
using UnityStandardAssets;
using UnityStandardAssets.Characters.FirstPerson;
using CompleteProject;

public class PlayerHealth : MonoBehaviour
{
    public int startingHealth = 100;
    public int currentHealth;
    public Slider healthSlider;
    public Image damageImage;
    public AudioClip deathClip;
    public float flashSpeed = 5f;
    public Color flashColour = new Color(1f, 0f, 0f, 0.1f);


    Animator anim;
    AudioSource playerAudio;
   FirstPersonController playerMovement;
    PlayerShooting playerShooting;
    bool isDead;
    bool damaged;


    void Awake ()
    {
        anim = GetComponent <Animator> ();
        playerAudio = GetComponent <AudioSource> ();
      playerMovement = GetComponent <FirstPersonController> ();
        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)
    {
        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;

      ScoreManager.score++;
    }


    public void RestartLevel ()
    {
        SceneManager.LoadScene (0);
    }
}
nao deu nenhum error 

Manawydan escreveu:certo poste a modificação que voce fez aki e se deu algum erro poste tambem.
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Qua maio 10, 2017 9:36 pm

Agora que vi que modifiquei o script errado aff
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Qua maio 10, 2017 9:43 pm

Código:
using UnityEngine;
using CompleteProject;

public class EnemyHealth : MonoBehaviour
{
    public int startingHealth = 100;
    public int currentHealth;
    public float sinkSpeed = 2.5f;
    public int scoreValue = 10;
    public AudioClip deathClip;


    Animator anim;
    AudioSource enemyAudio;
    ParticleSystem hitParticles;
    CapsuleCollider capsuleCollider;
    bool isDead;
    bool isSinking;


    void Awake ()
    {
        anim = GetComponent <Animator> ();
        enemyAudio = GetComponent <AudioSource> ();
        hitParticles = GetComponentInChildren <ParticleSystem> ();
        capsuleCollider = GetComponent <CapsuleCollider> ();

        currentHealth = startingHealth;
    }


    void Update ()
    {
        if(isSinking)
        {
            transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime);
        }
    }


    public void TakeDamage (int amount, Vector3 hitPoint)
    {
        if(isDead)
            return;

        enemyAudio.Play ();

        currentHealth -= amount;
           
        hitParticles.transform.position = hitPoint;
        hitParticles.Play();

        if(currentHealth <= 0)
        {
            Death ();
        }
    }


    void Death ()
    {
        isDead = true;

        capsuleCollider.isTrigger = true;

        anim.SetTrigger ("Dead");

        enemyAudio.clip = deathClip;
        enemyAudio.Play ();
      ScoreManager.score++;
    }


    public void StartSinking ()
    {
        GetComponent <UnityEngine.AI.NavMeshAgent> ().enabled = false;
        GetComponent <Rigidbody> ().isKinematic = true;
        isSinking = true;
        ScoreManager.score += scoreValue;
        Destroy (gameObject, 2f);
    }
}

continua sem aumentar
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Manawydan Qua maio 10, 2017 9:51 pm

Certo nao vi nenhum erro aparente, então o erro ser pq o metodo de tirar vida (TakeDamage) não esta sendo executado, no seu script de bala voce pode usar um OnTriggerEnter e verificar se o objeto que colidiu tem a tag Enemy para então pegar o componente EnemyHealth e executar o metodo TakeDamage.
Manawydan
Manawydan
Mestre
Mestre

PONTOS : 3464
REPUTAÇÃO : 198
Idade : 27
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://wad.ojooo.com/register.php?ref=ManawydanBr

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Qua maio 10, 2017 10:03 pm

Código:
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;

namespace CompleteProject
{
    public class PlayerShooting : MonoBehaviour
    {
        public int damagePerShot = 20;                  // The damage inflicted by each bullet.
        public float timeBetweenBullets = 0.15f;        // The time between each shot.
        public float range = 100f;                      // The distance the gun can fire.


        float timer;                                    // A timer to determine when to fire.
        Ray shootRay = new Ray();                      // A ray from the gun end forwards.
        RaycastHit shootHit;                            // A raycast hit to get information about what was hit.
        int shootableMask;                              // A layer mask so the raycast only hits things on the shootable layer.
        ParticleSystem gunParticles;                    // Reference to the particle system.
        LineRenderer gunLine;                          // Reference to the line renderer.
        AudioSource gunAudio;                          // Reference to the audio source.
        Light gunLight;                                // Reference to the light component.
      public Light faceLight;                        // Duh
        float effectsDisplayTime = 0.2f;                // The proportion of the timeBetweenBullets that the effects will display for.


        void Awake ()
        {
            // Create a layer mask for the Shootable layer.
            shootableMask = LayerMask.GetMask ("Shootable");

            // Set up the references.
            gunParticles = GetComponent<ParticleSystem> ();
            gunLine = GetComponent <LineRenderer> ();
            gunAudio = GetComponent<AudioSource> ();
            gunLight = GetComponent<Light> ();
         //faceLight = GetComponentInChildren<Light> ();
        }


        void Update ()
        {
            // Add the time since Update was last called to the timer.
            timer += Time.deltaTime;

#if !MOBILE_INPUT
            // If the Fire1 button is being press and it's time to fire...
         if(Input.GetButton ("Fire1") && timer >= timeBetweenBullets && Time.timeScale != 0)
            {
                // ... shoot the gun.
                Shoot ();
            }
#else
            // If there is input on the shoot direction stick and it's time to fire...
            if ((CrossPlatformInputManager.GetAxisRaw("Mouse X") != 0 || CrossPlatformInputManager.GetAxisRaw("Mouse Y") != 0) && timer >= timeBetweenBullets)
            {
                // ... shoot the gun
                Shoot();
            }
#endif
            // If the timer has exceeded the proportion of timeBetweenBullets that the effects should be displayed for...
            if(timer >= timeBetweenBullets * effectsDisplayTime)
            {
                // ... disable the effects.
                DisableEffects ();
            }
        }


        public void DisableEffects ()
        {
            // Disable the line renderer and the light.
            gunLine.enabled = false;
         faceLight.enabled = false;
            gunLight.enabled = false;
        }


        void Shoot ()
        {
            // Reset the timer.
            timer = 0f;

            // Play the gun shot audioclip.
            gunAudio.Play ();

            // Enable the lights.
            gunLight.enabled = true;
         faceLight.enabled = true;

            // Stop the particles from playing if they were, then start the particles.
            gunParticles.Stop ();
            gunParticles.Play ();

            // Enable the line renderer and set it's first position to be the end of the gun.
            gunLine.enabled = true;
            gunLine.SetPosition (0, transform.position);

            // Set the shootRay so that it starts at the end of the gun and points forward from the barrel.
            shootRay.origin = transform.position;
            shootRay.direction = transform.forward;

            // Perform the raycast against gameobjects on the shootable layer and if it hits something...
            if(Physics.Raycast (shootRay, out shootHit, range, shootableMask))
            {
                // Try and find an EnemyHealth script on the gameobject hit.
                EnemyHealth enemyHealth = shootHit.collider.GetComponent <EnemyHealth> ();

                // If the EnemyHealth component exist...
                if(enemyHealth != null)
                {
                    // ... the enemy should take damage.
                    enemyHealth.TakeDamage (damagePerShot, shootHit.point);
                }

                // Set the second position of the line renderer to the point the raycast hit.
                gunLine.SetPosition (1, shootHit.point);
            }
            // If the raycast didn't hit anything on the shootable layer...
            else
            {
                // ... set the second position of the line renderer to the fullest extent of the gun's range.
                gunLine.SetPosition (1, shootRay.origin + shootRay.direction * range);
            }
        }
    }
}
Script do tiro
Manawydan escreveu:Certo nao vi nenhum erro aparente, então o erro ser pq o metodo de tirar vida (TakeDamage) não esta sendo executado, no seu script de bala voce pode usar um OnTriggerEnter e verificar se o objeto que colidiu tem a tag Enemy para então pegar o componente EnemyHealth e executar o metodo TakeDamage.
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Manawydan Qua maio 10, 2017 10:20 pm

Ok mais coisas pra verificar, os Enemy estão na layer "Shootable"?
Quando voce não sabe ao certo onde esta o erro, uma boa idia seria usar print pra mostrar um mensagem na tela caso tal pedaço de codigo esta funcionando certinho.
Código:
if(Physics.Raycast (shootRay, out shootHit, range, shootableMask))
 {
 print("Detectou Raycast em Algo ok");
 // Try and find an EnemyHealth script on the gameobject hit.
 EnemyHealth enemyHealth = shootHit.collider.GetComponent <EnemyHealth> ();

 // If the EnemyHealth component exist...
 if(enemyHealth != null)
 {
 print("Enemy detectado ok, deveria sofre dano");
 // ... the enemy should take damage.
 enemyHealth.TakeDamage (damagePerShot, shootHit.point);
 }

 // Set the second position of the line renderer to the point the raycast hit.
 gunLine.SetPosition (1, shootHit.point);
 }
Verifique qual das mensagens aparece no console.
Manawydan
Manawydan
Mestre
Mestre

PONTOS : 3464
REPUTAÇÃO : 198
Idade : 27
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://wad.ojooo.com/register.php?ref=ManawydanBr

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Qua maio 10, 2017 10:33 pm

Manawydan escreveu:Ok mais coisas pra verificar, os Enemy estão na layer "Shootable"?
Quando voce não sabe ao certo onde esta o erro, uma boa idia seria usar print pra mostrar um mensagem na tela caso tal pedaço de codigo esta funcionando certinho.
Código:
if(Physics.Raycast (shootRay, out shootHit, range, shootableMask))
 {
 print("Detectou Raycast em Algo ok");
 // Try and find an EnemyHealth script on the gameobject hit.
 EnemyHealth enemyHealth = shootHit.collider.GetComponent <EnemyHealth> ();

 // If the EnemyHealth component exist...
 if(enemyHealth != null)
 {
 print("Enemy detectado ok, deveria sofre dano");
 // ... the enemy should take damage.
 enemyHealth.TakeDamage (damagePerShot, shootHit.point);
 }

 // Set the second position of the line renderer to the point the raycast hit.
 gunLine.SetPosition (1, shootHit.point);
 }
Verifique qual das mensagens aparece no console.
sim os inimigos estão na layer "Shootable".
fiz a modificaçao e nao apareceu nenhum error no console
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Qui maio 11, 2017 2:23 pm

Up!

ja tentei de todo jeito nao conseguir fazer esse sistema de score me ajudem por favor!
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Matrirxp Qui maio 11, 2017 3:18 pm

Voce tento a que eu te passei 
!!!!!!!!!!!!!!!!!
Matrirxp
Matrirxp
ProgramadorMaster

Masculino PONTOS : 3187
REPUTAÇÃO : 86
Idade : 21
Áreas de atuação : Programação: C#, Java, HLSL, CG, GLSL.
Modelagem 3D.
Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

https://www.youtube.com/channel/UCkngjEDMx9y_vW0t7Io05gg

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Qui maio 11, 2017 4:57 pm

Matrirxp escreveu:Voce tento a que eu te passei 
!!!!!!!!!!!!!!!!!
tentei utilizar mais deus erros no console.

e o meu projeto nao da spawn em uma bala, tem o script acima do meu tiro
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Matrirxp Qui maio 11, 2017 8:45 pm

manda as scripts do:
* tiro 
* player
* inimigo
Matrirxp
Matrirxp
ProgramadorMaster

Masculino PONTOS : 3187
REPUTAÇÃO : 86
Idade : 21
Áreas de atuação : Programação: C#, Java, HLSL, CG, GLSL.
Modelagem 3D.
Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

https://www.youtube.com/channel/UCkngjEDMx9y_vW0t7Io05gg

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Qui maio 11, 2017 9:07 pm

Tiro
Código:
using UnityEngine;

public class PlayerShooting : MonoBehaviour
{
 public int damagePerShot = 20;
 public float timeBetweenBullets = 0.15f;
 public float range = 100f;


 float timer;
 Ray shootRay = new Ray();
 RaycastHit shootHit;
 int shootableMask;
 ParticleSystem gunParticles;
 LineRenderer gunLine;
 AudioSource gunAudio;
 Light gunLight;
 float effectsDisplayTime = 0.2f;
 private bool TocouEmAtirar;


 void Awake()
 {
 shootableMask = LayerMask.GetMask("Shootable");
 gunParticles = GetComponent<ParticleSystem>();
 gunLine = GetComponent<LineRenderer>();
 gunAudio = GetComponent<AudioSource>();
 gunLight = GetComponent<Light>();
 }


 void Update()
 {
 timer += Time.deltaTime;

 if (TocouEmAtirar == true && timer >= timeBetweenBullets && Time.timeScale != 0) //Aqui eu troquei o Input.GetKey pela nossa nova variavel
 {
 Shoot();
 }

 if (timer >= timeBetweenBullets * effectsDisplayTime)
 {
 DisableEffects();
 }
 }


 public void DisableEffects()
 {
 gunLine.enabled = false;
 gunLight.enabled = false;
 }


 void Shoot()
 {
 timer = 0f;

 gunAudio.Play();

 gunLight.enabled = true;

 gunParticles.Stop();
 gunParticles.Play();

 gunLine.enabled = true;
 gunLine.SetPosition(0, transform.position);

 shootRay.origin = transform.position;
 shootRay.direction = transform.forward;

 if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
 {
 EnemyHealth enemyHealth = shootHit.collider.GetComponent<EnemyHealth>();
 if (enemyHealth != null)
 {
 enemyHealth.TakeDamage(damagePerShot, shootHit.point);
 }
 gunLine.SetPosition(1, shootHit.point);
 }
 else
 {
 gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);
 }
 }

 public void RecebeToque(bool transmissor) //Esse public void, vai receber os dados do seu botão da UI
 {
 TocouEmAtirar = transmissor;
 }
}


Player:
Código:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.SceneManagement;
using UnityStandardAssets;
using UnityStandardAssets.Characters.FirstPerson;

public class PlayerHealth : MonoBehaviour
{
    public int startingHealth = 100;
    public int currentHealth;
    public Slider healthSlider;
    public Image damageImage;
    public AudioClip deathClip;
    public float flashSpeed = 5f;
    public Color flashColour = new Color(1f, 0f, 0f, 0.1f);


    Animator anim;
    AudioSource playerAudio;
 FirstPersonController playerMovement;
    PlayerShooting playerShooting;
    bool isDead;
    bool damaged;


    void Awake ()
    {
        anim = GetComponent <Animator> ();
        playerAudio = GetComponent <AudioSource> ();
 playerMovement = GetComponent <FirstPersonController> ();
        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)
    {
        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;

    }


    public void RestartLevel ()
    {
        SceneManager.LoadScene (1);
    }
}

Inimigo:
Código:
using UnityEngine;
using CompleteProject;

public class EnemyHealth : MonoBehaviour
{
    public int startingHealth = 100;
    public int currentHealth;
    public float sinkSpeed = 2.5f;
    public int scoreValue = 10;
    public AudioClip deathClip;


    Animator anim;
    AudioSource enemyAudio;
    ParticleSystem hitParticles;
    CapsuleCollider capsuleCollider;
    bool isDead;
    bool isSinking;


    void Awake ()
    {
        anim = GetComponent <Animator> ();
        enemyAudio = GetComponent <AudioSource> ();
        hitParticles = GetComponentInChildren <ParticleSystem> ();
        capsuleCollider = GetComponent <CapsuleCollider> ();

        currentHealth = startingHealth;
    }


    void Update ()
    {
        if(isSinking)
        {
            transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime);
        }
    }


    public void TakeDamage (int amount, Vector3 hitPoint)
    {
        if(isDead)
            return;

        enemyAudio.Play ();

        currentHealth -= amount;
            
        hitParticles.transform.position = hitPoint;
        hitParticles.Play();

        if(currentHealth <= 0)
        {
            Death ();
        }
    }


    void Death ()
    {
        isDead = true;

        capsuleCollider.isTrigger = true;

        anim.SetTrigger ("Dead");

        enemyAudio.clip = deathClip;
        enemyAudio.Play ();
 ScoreManager.score++;
    }


    public void StartSinking ()
    {
        GetComponent <UnityEngine.AI.NavMeshAgent> ().enabled = false;
        GetComponent <Rigidbody> ().isKinematic = true;
        isSinking = true;
        ScoreManager.score += scoreValue;
        Destroy (gameObject, 2f);
    }
}

Score:

Código:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class ScoreManager : MonoBehaviour
{
    public static int score;


    Text text;


    void Awake ()
    {
        text = GetComponent <Text> ();
        score = 0;
    }


    void Update ()
    {
        text.text = "Score: " + score;
    }
}
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Manawydan Qui maio 11, 2017 11:17 pm

Como não estou conseguindo ver o erro tentaria por prints para debugar cada bloco de codigo pra saber o que esta sendo executado e o que não ta.
O metodo TakeDamage do Inimigo é executado? ele perde vida? o som dele é tocado?
Quanto mais informações nos passar mais facil sera tentarmos ajudar.
Manawydan
Manawydan
Mestre
Mestre

PONTOS : 3464
REPUTAÇÃO : 198
Idade : 27
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://wad.ojooo.com/register.php?ref=ManawydanBr

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Qui maio 11, 2017 11:24 pm

Manawydan escreveu:Como não estou conseguindo ver o erro tentaria por prints para debugar cada bloco de codigo pra saber o que esta sendo executado e o que não ta.
O metodo TakeDamage do Inimigo é executado? ele perde vida? o som dele é tocado?
Quanto mais informações nos passar mais facil sera tentarmos ajudar.
Simm, ele perde vida, o som é tocado, as particulas sao ativadas, ele ataca o player e mata o player, ele so nao da o "score" e o corpo dele nao é destruido
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Manawydan Sex maio 12, 2017 12:06 pm

Tente isso:
Inimigo:
Código:
using UnityEngine;
using CompleteProject;

public class EnemyHealth : MonoBehaviour
{
    public int startingHealth = 100;
    public int currentHealth;
    public float sinkSpeed = 2.5f;
    public int scoreValue = 10;
    public AudioClip deathClip;


    Animator anim;
    AudioSource enemyAudio;
    ParticleSystem hitParticles;
    CapsuleCollider capsuleCollider;
    bool isDead;
    bool isSinking;


    void Awake ()
    {
        anim = GetComponent <Animator> ();
        enemyAudio = GetComponent <AudioSource> ();
        hitParticles = GetComponentInChildren <ParticleSystem> ();
        capsuleCollider = GetComponent <CapsuleCollider> ();

        currentHealth = startingHealth;
    }


    void Update ()
    {
        if(isSinking)
        {
            transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime);
        }
    }


    public void TakeDamage (int amount, Vector3 hitPoint)
    {
        if(isDead)
            return;

        enemyAudio.Play ();

        currentHealth -= amount;
           
        hitParticles.transform.position = hitPoint;
        hitParticles.Play();

        if(currentHealth <= 0)
        {
            Death ();
        }
    }


    void Death ()
    {
      print("Death ok");
      currentHealth = 0;// setamos a vida pra 0 pra nao ficar negativa
        isDead = true;

        capsuleCollider.isTrigger = true;

        anim.SetTrigger ("Dead");

        enemyAudio.clip = deathClip;
        enemyAudio.Play ();
      
      // executamos o metodo StartSinking que não estava sendo usado
      StartSinking();
    }


    public void StartSinking ()
    {
        GetComponent <UnityEngine.AI.NavMeshAgent> ().enabled = false;
        GetComponent <Rigidbody> ().isKinematic = true;
        isSinking = true;
        ScoreManager.score += scoreValue;
      ScoreManager sm = (ScoreManager)FindObjectOfType(typeof(ScoreManager));
      sm.AddScore(scoreValue);
        Destroy (gameObject, 2f);
    }
}

Score:
Código:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class ScoreManager : MonoBehaviour
{
    int score;


    Text text;


    void Awake ()
    {
        text = GetComponent <Text> ();
        score = 0;
    }


    void Update ()
    {
        text.text = "Score: " + score;
    }
   
   public void AddScore(int ammount)
   {
      print("AddScore ok");
      score += ammount;
   }
}

Se não funcionar diga se os prints são exibidos no console.
Manawydan
Manawydan
Mestre
Mestre

PONTOS : 3464
REPUTAÇÃO : 198
Idade : 27
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://wad.ojooo.com/register.php?ref=ManawydanBr

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Matrirxp Sex maio 12, 2017 12:28 pm

Código:
using UnityEngine;
using CompleteProject;

public class EnemyHealth : MonoBehaviour
{
    public int startingHealth = 100;
    public int currentHealth;
    public float sinkSpeed = 2.5f;
    public int scoreValue = 10;
    public AudioClip deathClip;


    Animator anim;
    AudioSource enemyAudio;
    ParticleSystem hitParticles;
    CapsuleCollider capsuleCollider;
    bool isDead;
    bool isSinking;

    ScoreManager sm;
    GameObject ScoreGameObject;//Coloca o GameObject onde o ScoreManager esta

    void Awake ()
    {
        anim = GetComponent <Animator> ();
        enemyAudio = GetComponent <AudioSource> ();
        hitParticles = GetComponentInChildren <ParticleSystem> ();
sm = ScoreGameObject.GetComponent<ScoreManager>():
        capsuleCollider = GetComponent <CapsuleCollider> ();

        currentHealth = startingHealth;
    }


    void Update ()
    {
        if(isSinking)
        {
            transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime);
        }
    }


    public void TakeDamage (int amount, Vector3 hitPoint)
    {
        if(isDead)
            return;

        enemyAudio.Play ();

        currentHealth -= amount;
            
        hitParticles.transform.position = hitPoint;
        hitParticles.Play();

        if(currentHealth <= 0)
        {
            Death ();
        }
    }


    void Death ()
    {
      print("Death ok");
      currentHealth = 0;// setamos a vida pra 0 pra nao ficar negativa
        isDead = true;

        capsuleCollider.isTrigger = true;

        anim.SetTrigger ("Dead");

        enemyAudio.clip = deathClip;
        enemyAudio.Play ();
      
      // executamos o metodo StartSinking que não estava sendo usado
      StartSinking();
    }


    public void StartSinking ()
    {
        GetComponent <UnityEngine.AI.NavMeshAgent> ().enabled = false;
        GetComponent <Rigidbody> ().isKinematic = true;
        isSinking = true;
        sm.score += scoreValue;
      sm.AddScore(scoreValue);
        Destroy (gameObject, 2f);
    }
}
Matrirxp
Matrirxp
ProgramadorMaster

Masculino PONTOS : 3187
REPUTAÇÃO : 86
Idade : 21
Áreas de atuação : Programação: C#, Java, HLSL, CG, GLSL.
Modelagem 3D.
Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

https://www.youtube.com/channel/UCkngjEDMx9y_vW0t7Io05gg

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Matrirxp Sex maio 12, 2017 12:38 pm

Código:
using UnityEngine;
using System.Collections;

namespace CompleteProject
{
    public class ScoreManager : MonoBehaviour
    {
        public int score;        
   public UnityEngine.UI.Text text;//coloca a label(Text UI) aqui

        void Update ()
        {
            
            text.text = "Score: " + score;
        }
    }
}
Matrirxp
Matrirxp
ProgramadorMaster

Masculino PONTOS : 3187
REPUTAÇÃO : 86
Idade : 21
Áreas de atuação : Programação: C#, Java, HLSL, CG, GLSL.
Modelagem 3D.
Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

https://www.youtube.com/channel/UCkngjEDMx9y_vW0t7Io05gg

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Sex maio 12, 2017 12:50 pm

[RESOLVIDO] Score ao matar inimigo Ci5ZLHs
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Matrirxp Sex maio 12, 2017 1:02 pm

Código:
using UnityEngine;
using System.Collections;

    public class ScoreManager : MonoBehaviour
    {
        public int score;        
   public UnityEngine.UI.Text text;//coloca a label(Text UI) aqui

        void Update ()
        {
            
            text.text = "Score: " + score;
        }
    }
Matrirxp
Matrirxp
ProgramadorMaster

Masculino PONTOS : 3187
REPUTAÇÃO : 86
Idade : 21
Áreas de atuação : Programação: C#, Java, HLSL, CG, GLSL.
Modelagem 3D.
Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

https://www.youtube.com/channel/UCkngjEDMx9y_vW0t7Io05gg

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Sex maio 12, 2017 1:17 pm

[RESOLVIDO] Score ao matar inimigo 5KgjGUl
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Matrirxp Sex maio 12, 2017 1:21 pm

Código:
using UnityEngine;
using CompleteProject;

public class EnemyHealth : MonoBehaviour
{
    public int startingHealth = 100;
    public int currentHealth;
    public float sinkSpeed = 2.5f;
    public int scoreValue = 10;
    public AudioClip deathClip;


    Animator anim;
    AudioSource enemyAudio;
    ParticleSystem hitParticles;
    CapsuleCollider capsuleCollider;
    bool isDead;
    bool isSinking;

    ScoreManager sm;
    GameObject ScoreGameObject;//Coloca o GameObject onde o ScoreManager esta

    void Awake ()
    {
        anim = GetComponent <Animator> ();
        enemyAudio = GetComponent <AudioSource> ();
        hitParticles = GetComponentInChildren <ParticleSystem> ();
sm = ScoreGameObject.GetComponent<ScoreManager>():
        capsuleCollider = GetComponent <CapsuleCollider> ();

        currentHealth = startingHealth;
    }


    void Update ()
    {
        if(isSinking)
        {
            transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime);
        }
    }


    public void TakeDamage (int amount, Vector3 hitPoint)
    {
        if(isDead)
            return;

        enemyAudio.Play ();

        currentHealth -= amount;
            
        hitParticles.transform.position = hitPoint;
        hitParticles.Play();

        if(currentHealth <= 0)
        {
            Death ();
        }
    }


    void Death ()
    {
      print("Death ok");
      currentHealth = 0;// setamos a vida pra 0 pra nao ficar negativa
        isDead = true;

        capsuleCollider.isTrigger = true;

        anim.SetTrigger ("Dead");

        enemyAudio.clip = deathClip;
        enemyAudio.Play ();
      
      // executamos o metodo StartSinking que não estava sendo usado
      StartSinking();
    }


    public void StartSinking ()
    {
        GetComponent <UnityEngine.AI.NavMeshAgent> ().enabled = false;
        GetComponent <Rigidbody> ().isKinematic = true;
        isSinking = true;
        sm.score += scoreValue;
        Destroy (gameObject, 2f);
    }
}
Matrirxp
Matrirxp
ProgramadorMaster

Masculino PONTOS : 3187
REPUTAÇÃO : 86
Idade : 21
Áreas de atuação : Programação: C#, Java, HLSL, CG, GLSL.
Modelagem 3D.
Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

https://www.youtube.com/channel/UCkngjEDMx9y_vW0t7Io05gg

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Sex maio 12, 2017 1:30 pm

[RESOLVIDO] Score ao matar inimigo PL2XDGi
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Matrirxp Sex maio 12, 2017 1:35 pm

Código:
using UnityEngine;
using CompleteProject;

public class EnemyHealth : MonoBehaviour
{
    public int startingHealth = 100;
    public int currentHealth;
    public float sinkSpeed = 2.5f;
    public int scoreValue = 10;
    public AudioClip deathClip;


    Animator anim;
    AudioSource enemyAudio;
    ParticleSystem hitParticles;
    CapsuleCollider capsuleCollider;
    bool isDead;
    bool isSinking;

    ScoreManager sm;
    public GameObject ScoreGameObject;//Coloca o GameObject onde o ScoreManager esta ||||| SETA ISSOOOOOOOOO
piblic GameObject Inimigo;//Inimigo ||||||||||||||||| ISSO TBM

    void Awake ()
    {
        anim = GetComponent <Animator> ();
        enemyAudio = GetComponent <AudioSource> ();
        hitParticles = GetComponentInChildren <ParticleSystem> ();
sm = ScoreGameObject.GetComponent<ScoreManager>():
        capsuleCollider = GetComponent <CapsuleCollider> ();

        currentHealth = startingHealth;
    }


    void Update ()
    {
        if(isSinking)
        {
            transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime);
        }
    }


    public void TakeDamage (int amount, Vector3 hitPoint)
    {
        if(isDead)
            return;

        enemyAudio.Play ();

        currentHealth -= amount;
            
        hitParticles.transform.position = hitPoint;
        hitParticles.Play();

        if(currentHealth <= 0)
        {
            Death ();
        }
    }


    void Death ()
    {
      print("Death ok");
      currentHealth = 0;// setamos a vida pra 0 pra nao ficar negativa
        isDead = true;

        anim.SetTrigger ("Dead");

        enemyAudio.clip = deathClip;
        enemyAudio.Play ();
      
      // executamos o metodo StartSinking que não estava sendo usado
      StartSinking();
    }


    public void StartSinking ()
    {
        GetComponent <UnityEngine.AI.NavMeshAgent> ().enabled = false;
        GetComponent <Rigidbody> ().isKinematic = true;
        isSinking = true;
        sm.score += scoreValue;
        Destroy (Inimigo);
    }
}
Matrirxp
Matrirxp
ProgramadorMaster

Masculino PONTOS : 3187
REPUTAÇÃO : 86
Idade : 21
Áreas de atuação : Programação: C#, Java, HLSL, CG, GLSL.
Modelagem 3D.
Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

https://www.youtube.com/channel/UCkngjEDMx9y_vW0t7Io05gg

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Sex maio 12, 2017 1:40 pm

VLWW MEU AMIGO MUITO OBRIGADO MESMO FUNCIONOU!  :D :D :D

SO QUE QUANDO ELE MORRE TA DESAPARECENDO IMEDIATAMENTE NAO TA NEM FAZENDO A ANIMAÇAO "Dead"!

MAIS OBRIGADO !
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Matrirxp Sex maio 12, 2017 1:56 pm

Código:
using UnityEngine;
using CompleteProject;

public class EnemyHealth : MonoBehaviour
{
    public int startingHealth = 100;
    public int currentHealth;
    public float sinkSpeed = 2.5f;
    public int scoreValue = 10;
    public AudioClip deathClip;


    Animator anim;
    AudioSource enemyAudio;
    ParticleSystem hitParticles;
    CapsuleCollider capsuleCollider;
    bool isDead;
    bool isSinking;

    ScoreManager sm;
    public GameObject ScoreGameObject;//Coloca o GameObject onde o ScoreManager esta ||||| SETA ISSOOOOOOOOO
piblic GameObject Inimigo;//Inimigo ||||||||||||||||| ISSO TBM

public float DelayDeath;//Daley para a destroy do inimigo 
float Ctime;

    void Awake ()
    {
        anim = GetComponent <Animator> ();
        enemyAudio = GetComponent <AudioSource> ();
        hitParticles = GetComponentInChildren <ParticleSystem> ();
sm = ScoreGameObject.GetComponent<ScoreManager>():
        capsuleCollider = GetComponent <CapsuleCollider> ();

        currentHealth = startingHealth;
    }


    void Update ()
    {
        if(isSinking)
        {
            transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime);
        }
    }


    public void TakeDamage (int amount, Vector3 hitPoint)
    {
        if(isDead)
            return;

        enemyAudio.Play ();

        currentHealth -= amount;
            
        hitParticles.transform.position = hitPoint;
        hitParticles.Play();

        if(currentHealth <= 0)
        {
            Death ();
        }
    }


    void Death ()
    {
      print("Death ok");
      currentHealth = 0;// setamos a vida pra 0 pra nao ficar negativa
        isDead = true;

        anim.SetTrigger ("Dead");

        enemyAudio.clip = deathClip;
        enemyAudio.Play ();
      
      // executamos o metodo StartSinking que não estava sendo usado
      StartSinking();
    }


    public void StartSinking ()
    {
        GetComponent <UnityEngine.AI.NavMeshAgent> ().enabled = false;
        GetComponent <Rigidbody> ().isKinematic = true;
        isSinking = true;
        sm.score += scoreValue;
Ctime += 1 * Time.deltaTime;
if(Ctime == DelayDeath){     
   Destroy (Inimigo);
}    

}
}


Tenta isso
Matrirxp
Matrirxp
ProgramadorMaster

Masculino PONTOS : 3187
REPUTAÇÃO : 86
Idade : 21
Áreas de atuação : Programação: C#, Java, HLSL, CG, GLSL.
Modelagem 3D.
Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

https://www.youtube.com/channel/UCkngjEDMx9y_vW0t7Io05gg

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Sex maio 12, 2017 3:29 pm

FUNCIONOU AGORA TEM UM TEMPINHO ANTES DELE DESTRUIR, QUE ERROR É ESSE?
[RESOLVIDO] Score ao matar inimigo MPF1SfE
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Sex maio 12, 2017 4:51 pm

EI ESTOU COM UM PROBLEMINHA O PREFAB DO MEU INIMIGO NAO FICA NA SCENA PORQUE ELE TEM SPAWN E NAO CONSIGO LINKAR O PUBLIC GameObject onde o ScoreManager ESTA
DEU PARA ENTENDER??
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Matrirxp Sáb maio 13, 2017 10:40 pm

Código:
ScoreGameObject = GameObject.Find("Name GameObject");
Matrirxp
Matrirxp
ProgramadorMaster

Masculino PONTOS : 3187
REPUTAÇÃO : 86
Idade : 21
Áreas de atuação : Programação: C#, Java, HLSL, CG, GLSL.
Modelagem 3D.
Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

https://www.youtube.com/channel/UCkngjEDMx9y_vW0t7Io05gg

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Sáb maio 13, 2017 11:38 pm

nÃO DEU CERTO
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por Matrirxp Dom maio 14, 2017 11:09 am

pq???
voce colocou o nome certo do objeto no find?
Matrirxp
Matrirxp
ProgramadorMaster

Masculino PONTOS : 3187
REPUTAÇÃO : 86
Idade : 21
Áreas de atuação : Programação: C#, Java, HLSL, CG, GLSL.
Modelagem 3D.
Respeito as regras : [RESOLVIDO] Score ao matar inimigo Aad8pUi

https://www.youtube.com/channel/UCkngjEDMx9y_vW0t7Io05gg

Ir para o topo Ir para baixo

Resolvido Re: [RESOLVIDO] Score ao matar inimigo

Mensagem por bruxamissi Dom maio 14, 2017 5:35 pm

CONSEGUI JÁ MEU AMIGO, MUITO OBRIGADO PELA AJUDA VOU DEIXAR O SCRIPT ABAIXO VAI QUE AJUDA ALGUEM:
Código:
using UnityEngine;
using CompleteProject;
using UnityEngine.UI;
using System.Collections;

public class EnemyHealth : MonoBehaviour
{
 public int startingHealth = 100;
 public int currentHealth;
 public float sinkSpeed = 2.5f;
 public int scoreValue = 10;
 public AudioClip deathClip;
 Animator anim;
 AudioSource enemyAudio;
 ParticleSystem hitParticles;
 CapsuleCollider capsuleCollider;
 bool isDead;
 bool isSinking;

 ScoreManager sm;

 public GameObject ScoreGameObject;//Coloca o GameObject onde o ScoreManager esta ||||| SETA ISSOOOOOOOOO
 public GameObject Inimigo; //Inimigo ||||||||||||||||| ISSO TBM

 public float DelayDeath;//Daley para a destroy do inimigo
 float Ctime;

 void Start ()
 {
 StartCoroutine ("Timer");
 if (ScoreGameObject == null) {
 ScoreGameObject = GameObject.FindWithTag ("ScoreGameObject");
 }
 }

 void Awake ()
 {
 anim = GetComponent <Animator> ();
 enemyAudio = GetComponent <AudioSource> ();
 hitParticles = GetComponentInChildren <ParticleSystem> ();
 capsuleCollider = GetComponent <CapsuleCollider> ();
 currentHealth = startingHealth;
 }


 void Update ()
 {
 if(isSinking)
 {
 transform.Translate (-Vector3.up * sinkSpeed * Time.deltaTime);
 }
 }


 public void TakeDamage (int amount, Vector3 hitPoint)
 {
 if(isDead)
 return;

 enemyAudio.Play ();

 currentHealth -= amount;

 hitParticles.transform.position = hitPoint;
 hitParticles.Play();

 if(currentHealth <= 0)
 {
 Destroir ();
 Death ();
 }
 }


 void Death ()
 {
 //print("Death ok");
 currentHealth = 0;// setamos a vida pra 0 pra nao ficar negativa
 isDead = true;

 anim.SetTrigger ("Dead");

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

 // executamos o metodo StartSinking que não estava sendo usado
 StartSinking();
 }


 public void StartSinking ()
 {
 GetComponent <UnityEngine.AI.NavMeshAgent> ().enabled = false;
 GetComponent <Rigidbody> ().isKinematic = true;
 isSinking = true;

 sm.score += scoreValue;

 }

 IEnumerator Timer () {
 yield return new WaitForSeconds (0.1f);
 sm = ScoreGameObject.GetComponent<ScoreManager> ();
 }

 public void Destroir () {
 Ctime += 1 * Time.deltaTime;
 if (Ctime >= DelayDeath) {    
 Destroy (Inimigo, 3);
 }
 }
}
bruxamissi
bruxamissi
Avançado
Avançado

Masculino PONTOS : 3025
REPUTAÇÃO : 17
Idade : 24
Respeito as regras : [RESOLVIDO] Score ao matar inimigo WvDYdlf

https://www.youtube.com/channel/UCPtkRtiJCQKFVz80fE9kIeA

Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos