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

Meus zumbis nao se mexem

Olá, eu rodo o codigo e meus zumbis nao mudam de posição

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

public class ControlaInimigo : MonoBehaviour{
    public GameObject Jogador;


    // Start is called before the first frame update
    void Start(){

    }

    // Update is called once per frame
    void Update(){

    }

    private void FixedUpdate(){
        GetComponent<Rigidbody>().MovePosition
           (GetComponent<Rigidbody>().position +
           Jogador.transform.position);
    }

}
4 respostas

Oi, Paulo, tudo bem?

Aparece algum erro no seu console? Você preencheu a variável Jogador no Inspector?

Está dando sim, nem havia percebido. mas nao consigo entender o erro

MissingComponentException: There is no 'Rigidbody' attached to the "Zumbi (2)" game object, but a script is trying to access it. You probably need to add a Rigidbody to the game object "Zumbi (2)". Or your script needs to check if the component is attached before using it. UnityEngine.Rigidbody.get_position () <0x4212e240 + 0x0006a> in <31353b3f2d2e434595cbfe07fbec4072>:0 ControlaInimigo.FixedUpdate () (at Assets/Scripts/ControlaInimigo.cs:20)

solução!

Descobri o erro, esqueci de colocar o rigidbody

Boa, Paulo, sempre dê uma olhada nos erros porque eles mostram muita informação :)

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