FIXED IT
Go to Inspector, choose Ellipsoid Particale Emitter, uncheck “Simulate In World Space”
Hey, so im having this problem that if i shoot, i go threw my muzzle flash. Im using particles, here’s the little script that i wrote:
using UnityEngine;
using System.Collections;
public class Shootings : MonoBehaviour {
public Transform bulletPrefab;
public Transform Spawn;
public bool ImFacingLeft;
public Transform muzzelFlash;
void Start ()
{
}
void Update ()
{
if (Input.GetButtonDown(“Fire1”))
{
Transform muzzle = Instantiate(muzzelFlash, Spawn.position, Spawn.transform.rotation) as Transform;
muzzle.transform.parent = Spawn;
}
if(Input.GetKeyDown(KeyCode.A))
{
ImFacingLeft = true;
}
if(Input.GetKeyDown(KeyCode.D))
{
ImFacingLeft = false;
}
if (Input.GetButtonDown(“Fire1”))
{
FireBullet();
}
}
void FireBullet(){
//Clone of the bullet
GameObject Clone;
Clone = Instantiate(bulletPrefab, Spawn.position,Spawn.transform.rotation) as GameObject;
if(ImFacingLeft == false)
{
Clone.rigidbody2D.AddForce(Vector2.right * 50);
}
if(ImFacingLeft == true)
{
Clone.rigidbody2D.AddForce(Vector2.right * -50); }
}
}