Hi everyone I don’t usually post up and ask for help, but I’m kind of at that point where I REALLY need help. I’m usually working with javascript but I heard C# is better for mobile games, and etc.
So I created a particle system that’s part of my Player Game Object. THE CODE WORKS!
But my real PROBLEM IS: I see the shuriken image after the particle explodes and it remains there and doesn’t disappear. I’m assuming I have to remove the “clones” it makes.
This script is under my Player Game Object.
This is my code:
"
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
//Vector3 velocity = Vector3.zero;
public float jumpSpeed = 150f;
public float forwardSpeed = 4f;
public GameObject SpawnParticle;
//Booleans;
bool didJump = false;
public bool dead = false;
float deathCoolDown;
public bool godMode = false;
[SerializeField]
private GameObject gameOverUI;
// Use this for initialization;
void Start () {
Instantiate (SpawnParticle, this.transform.position, this.transform.rotation);
}
// Do Graphics and Input Updates Here!;
void Update() {
if (dead) {
deathCoolDown -= Time.deltaTime;
if (deathCoolDown <= 0) {
gameOverUI.SetActive (true);
//DestroyObject (Player1); (IGNORE THIS PART!)
}
}
if(Input.GetMouseButtonDown(0)) {
didJump = true;
}
}
// Do Physics Engine Updates Here!;
void FixedUpdate () {
if (dead)
return;
GetComponent().AddForce (Vector2.right * forwardSpeed);
if (didJump) {
GetComponent ().AddForce (Vector2.up * jumpSpeed);
didJump = false;
}
}
void OnCollisionEnter2D(Collision2D collision) {
if (godMode)
return;
dead = true;
Instantiate (SpawnParticle, this.transform.position, this.transform.rotation);
deathCoolDown = 0.3f;
}
}
"