Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Não consigo adc o script de movimentaçao ao zumbi

ele fica apontando erro na linha 39, mas sempre que eu tento colocar o script de movintacao no prefab do zumbi ele da erro e aparece que ta dando erro na calsse https://drive.google.com/file/d/1OGQrOr7afJeetA2ImPPsVb28OLpxtsBt/view?usp=sharing

Assets\scripts de programa��o\zumbi.cs(39,27): error CS1061: 'Movimentaca' does not contain a definition for 'Movimentaca' and no accessible extension method 'Movimentaca' accepting a first argument of type 'Movimentaca' could be found (are you missing a using directive or an assembly reference?)

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

public class Movimentaca : MonoBehaviour
{
    private Rigidbody meurigidbody;
    // Start is called before the first frame update

    void Awake()
    {
        meurigidbody = GetComponent<Rigidbody>();
    }
    public void Movimentar(Vector3 direcao, float velocidade)
    {
        meurigidbody.MovePosition(meurigidbody.position + direcao.normalized * velocidade * Time.deltaTime);

    }
    public void Rotacionar(Vector3 direcao)
    {
        Quaternion novarota = Quaternion.LookRotation(direcao);
        meurigidbody.MoveRotation(novarota);
    }

}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class zumbi : MonoBehaviour
{
    // adc jogador como objeto pro zumbi seguir
    public GameObject jogador;
    public float velocidade = 5;
    private Animator animator;
    private Movimentaca meupersonagem;
    void Start()
    {
        jogador = GameObject.FindWithTag("jogador");
        int gerazumbi = Random.Range(1, 28);
        transform.GetChild(gerazumbi).gameObject.SetActive(true);
        animator = GetComponent<Animator>();
        meupersonagem = GetComponent<Movimentaca>();
    }


    void Update()
    {

    }
    void FixedUpdate ()
    {


        float distancia = Vector3.Distance(transform.position, jogador.transform.position);
        Vector3 direcao = jogador.transform.position - transform.position;
        // zumbi olhando pro personagem
        meupersonagem.Rotacionar(direcao);

        if (distancia > 2.5)
        {
            // zumbi seguir

            meupersonagem.Movimentaca(direcao, velocidade);
            animator.SetBool("ataque", false);
        }
        else
        {
            animator.SetBool("ataque", true);
        }

    }
    void AtacaJogador()
    {
        int dano = Random.Range(20, 30);
        jogador.GetComponent<personagem>().TomarDano (dano);

    }
}
2 respostas
solução!

Oi, Eduardo, tudo bem?

O problema parece estar nessa linha:

meupersonagem.Movimentaca(direcao, velocidade);

Acho que você queria chamar o método Movimentar certo?

deu certo professor

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software