Jump to content

Prefab attached to other prefab


Recommended Posts

Hi! I am currently making an item that spawn effect (in this case a prefab) on the item's owner when equipped and gone when unequipped.
I understand how the equip and unequip works,

What i want to ask is, how to make a prefab spawn and "attach" on another prefab?

So, when the "attached" prefab is moving, the "attaching" prefab is moving too. A simple example is like aura thing (see attached image).

Archmage.gif

Link to comment
Share on other sites

I'm guessing you would insert this code into whatever/whenever your character's wants his prefab attached

Spoiler

   local fx = SpawnPrefab("YOUR PREFAB NAME HERE")
   if fx ~= nil then
      fx.entity:SetParent(inst.entity)

	  fx:DoTaskInTime(10, function() fx:Remove() end) -- Incase you'd want it go be removed after a certain amount of time, i Htink this'll work.
   end

 

hopefully, yhis works for you :D!

Link to comment
Share on other sites

@SuperDavid Your code works but the prefab didn't appear correctly, i did some search on related topics and found your topics.

Quote

I think this fixed my problem, hopefully. So, hopefully no more help needed on this :).


local fx = SpawnPrefab("spawn_fx_medium")
            if fx ~= nil then
               fx.entity:SetParent(act.target.entity)
			   fx.entity:AddFollower()
               fx.Follower:FollowSymbol(act.target.GUID, "torso", 0, 0, 0)
            end

And i added it up with some changes, it works now! Thanks! 

Edited by Dear_J
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...