Ayuda crear script de enemigo

Hola bueno espero que me ayuden con un script para le enemigo de mi juego.Bueno el script es que el enemigo persigue al personaje no como slender apareciéndose sino que el enemigo lo persigue caminando y después de 10s desaparece.

E echo varios intentos pero todos terminan en errores y nunca me sirven espero que me puedan ayudar.

Te recomiendo que escribas en ingles, y que enseñes el codigo que mas se ha acercado a lo que deseas para que los demas te puedan ayudar o decir la parte la cual te da problemas.

I might be able to help you with the following script :

transform.Translate (Vector3(Spanish, To, English), Space.World);

:slight_smile:

2 Likes

tanks I probe this script tanks

help in the spanish to english I should put

locogamer, podias pasarme el sript q te funciono? porfavor te lo agradeceria mucho

hey alguien puede ayudarme

es que necesito un script de enemigo y no se donde recurrir he probado mucho

Necesito ayuda para hacer fácilmente un enemigo que patrulle, se detenga algunas veces, que persiga y ataque… para unity 5.5 (personal)

buenas para hacer que el enemigo persiga al jugador usa esta uno de estos scripts.
este esta en unityscript:
#pragma strict

// Aplicar a “enemigo” que contenga:
// Rigidbody
// Collider (de preferencia usar Capsule o Cube)
// En Rigidbody palomear los constrains de Freeze Rotation en X y en Z

var Player: Transform; //Asignar el personaje al que seguirán
var MoveSpeed:float = 4; //Establecer velocidad de persecución
var MaxDist:float = 20; //Establecer distancia máxima a la que lo seguirá
var MinDist:float = 1;//Establecer distancia mínima a la que lo seguirá

function Start () {

}

function Update () {
var EnemyPos = transform.position;
var PlayerPos = Player.position;
var distancia = Vector3.Distance(EnemyPos,PlayerPos);

if( distancia >= MinDist && distancia <= MaxDist ){
var targetPos = new Vector3( Player.position.x,
this.transform.position.y,
Player.position.z);
transform.LookAt(targetPos);
transform.position += transform.forwardMoveSpeedTime.deltaTime;

}
}

////////////////////////////////////////////////////este otro esta en c#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class perseguirT : MonoBehaviour {

public int MoveSpeed;
public float MaxDist;
public float MinDist;
// Use this for initialization
void Start () {

}

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

Transform Player = transformplayer.Player;
Vector3 EnemyPos = transform.position;
Vector3 PlayerPos = Player.position;
float distancia = Vector3.Distance(EnemyPos,PlayerPos);

if( distancia >= MinDist && distancia <= MaxDist ){
Vector3 targetPos = new Vector3( Player.position.x,
this.transform.position.y,
Player.position.z);
transform.LookAt(targetPos);
transform.position += transform.forwardMoveSpeedTime.deltaTime;

}

}
}
//////////////////////////// son casi iguales pero te recomiendo el primero tenes que poner en el inspector distancia minima maxima velocidad y a quien persigue pera hacer que desaparesca creo que si pone destroy(gameobject,5) tardaria 5 segundos en morir si lo pones en el start con 10 serviria aunque deberias rebuscar un poco mas.
///////////////////////////////para el ultimo que pidio un amigo que patrulle estas obligado a usar nav mesh es lo mejor vas a tener que aprender a usarlo

Te conviene buscar un tutorial completo de inteligencia artificial así lo podes aprender bien. sino vas a terminar con un script muy simple que no va a hacer lo que querés. Un saludo.

Transformar jugador;
UnityEngine.AI.NavMeshAgent nav;
// Se llama a Start antes de la actualización del primer cuadro
vacío Inicio ()
{
jugador = GameObject.findGameObjectWithtag (“Granful”).Transform;
nav = GetComponet <UnityEngine.AI.NavMeshAgent>();
}

// La actualización se llama una vez por marco
actualización nula ()
{
nav.SetDestination(player.position);
}
}

hgo esta mal no me funciona

ayuda tengo problema para que el enemigo se gire cuando va atacar al jugador se vuelve loco

English forum here.

Please don’t necro-post. If you have a new question, make a new post. It’s FREE!!

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

This is the bare minimum of information to report:

  • what you want
  • what you tried
  • what you expected to happen
  • what actually happened, log output, variable values, and especially any errors you see
  • links to documentation you used to cross-check your work (CRITICAL!!!)

The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: https://discussions.unity.com/t/481379

  • Do not TALK about code without posting it.
  • Do NOT post unformatted code.
  • Do NOT retype code. Use copy/paste properly using code tags.
  • Do NOT post screenshots of code.
  • Do NOT post photographs of code.
  • ONLY post the relevant code, and then refer to it in your discussion.