Bien lo que vamos hacer ahora es que nuestro personaje el Policía haga polvo al correr
Vamos a la carpeta de fútbol y elegimos «Material»
Una vez creado la Materia vamos a «Standard» y buscamos «Alpha Blended» Y pinchamos sobre ello
Bien ahora pinchamos sobre None (Texture) «Select» y seleccionamos la imagen nuestra una vez hecho esto vamos a crear partículas
Vamos a «Effects» Y «Particle System»
Bien vamos a Renderer que esta abajo vamos a Material y seleccionamos el Materias que hemos escogido
Bien así nos quedara ahora vamos a crear un Script
Crearemos un script para que la animación dure un segundo
using System.Collections; using System.Collections.Generic; using UnityEngine; public class desaparecer : MonoBehaviour { // Start is called before the first frame update void Start() { Destroy(gameObject, 1f); } // Update is called once per frame void Update() { } }
bien ahora os voy a poner el script del que tenemos que poner al policía
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Personajescript : MonoBehaviour { public float speed; private Rigidbody2D myRigibody; private Vector3 mover; private Animator animator; Vector2 mov; public GameObject correr_polvo;//////adjuntar void Start() { animator = GetComponent<Animator>(); myRigibody = GetComponent<Rigidbody2D>(); } void Update() { mover = Vector3.zero; mover.x = Input.GetAxisRaw("Horizontal"); mover.y = Input.GetAxisRaw("Vertical"); UpdateAnimationAdnMove(); HandleMovement(); } void UpdateAnimationAdnMove() { if (mover != Vector3.zero) { moveCharacter(); animator.SetFloat("MovX", mover.x); animator.SetFloat("MovY", mover.y); animator.SetBool("moving", true); } else { animator.SetBool("moving", false); } } void moveCharacter() { myRigibody.MovePosition(transform.position + mover * speed * Time.deltaTime); } private void HandleMovement() { if (Input.GetKeyDown(KeyCode.T)) { float dashDistance = 3f; transform.position += mover * dashDistance; } if (Input.GetKeyDown(KeyCode.T)) //////// adjuntar el script { Instantiate(correr_polvo, transform.position, Quaternion.identity); } }
Bien ahora vamos a cambiar el nombre a las partículas y despues la vamos a arrastras a la carpeta de Prefab
bien y lo borramos de aquí
y de la carpeta de prefab la copiamos al script del Policía
Y lo arrastramos como yo ya lo tengo al Script del policía..