joint two Sprite with toghether

Hi.

I have a space ship and when Press SPACE key, it shoot and show fire splash at fire position. but when I moving the player and press SPACE key, fire Splash not is fire position.also I used Hing Join 2D for fix this problem but this problem is also exist. anyone know how can fix this problem?

Thanks.

this is my video for better understand my mean.

Why not make the fireballs children of the spaceship? That way they’d stay in the same place relative to the spaceship.

I made two children empty Gameobject and with below code I say make fire.

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

public class PlayerController : MonoBehaviour
{

    public GameObject BulletExplosion;
    Transform Rocket_1, Rocket_2;

    // Use this for initialization
    void Start ()
    {     
        Rocket_1 = transform.FindChild ("Rocket 1 Position");
        Rocket_2 = transform.FindChild ("Rocket 2 Position");
    }
 
    // Update is called once per frame
    void Update ()
    {
        PlayerFireRocket ();
    }
     
    //============================================================= Functions =============================================================

    //============================================================= Fire Rocket
    void PlayerFireRocket()
    {
        if (Input.GetKeyDown (KeyCode.Space))
        {
            Instantiate (BulletExplosion, Rocket_1.position, Quaternion.identity);
            Instantiate (BulletExplosion, Rocket_2.position, Quaternion.identity);
        }
    }

}

Also, make sure the Particle System Simulation Space is set to local: https://docs.unity3d.com/Manual/PartSysMainModule.html

I don’t use Particle system. it’s a sprite explosion.

Oh, you fooled me :slight_smile:

The problem is that once you’re instantiating the sprite, it’s its own object that isn’t a child of the rocket. So you need to instantiate it as a child of the object.

Here’s an interesting doc: https://docs.unity3d.com/ScriptReference/Object.Instantiate.html

Specifically: public static Object Instantiate(Object original, Vector3 position, Quaternion rotation, Transform parent);

So for example:

Instantiate(PrefabToSpawnAsChild, transform.position, Quaternion.identity, transform);

In plain man words, Instantiate(Prefab to spawn, where to spawn it, rotation, parent transform);

Thanks. No work very well.:slight_smile: