hi all!
thanks for taking a look
i am attempting to instantiate a vfx prefab with the transform of an existing game object, and then parent that instantiated object to another object.
the desired effect is to have vfx spawn off a character’s hand, and then travel with the character animation while retaining the position and orientation of its parent object.
in the code below, if the (Transform gauntletL_vfx) is left empty, the object will be instantiated but without retaining its parent’s position.
as you can tell, i am new to scripting. any feedback is welcome.
thanks!
using UnityEngine;
using System.Collections;
public class InstantiateGauntletVFX : MonoBehaviour
{
public GameObject gauntletVFX_01;
public Transform gauntletL_vfx;
public void OnVFXTrigger (Transform gauntletL_vfx)
{
Instantiate(gauntletVFX_01, gauntletL_vfx.position, gauntletL_vfx.rotation);
gauntletVFX_01.transform.SetParent(gauntletL_vfx, false);
}
}