Jump to content

Need help with spawning prefab.


Recommended Posts

Hello, I need help if someone can help me please :)!

So, when my character gets hit on a certain event this happens 

local x, y, z = inst.Transform:GetWorldPosition()
local pufffx = SpawnPrefab("small_puff")
pufffx.Transform:SetPosition(x, y, z)
pufffx.Transform:SetScale(2,2,2)

Now the thing is i'd like to know is there a way to make the "small_puff" prefab spawn a little in front of him instead of right where he's standing?

When it spawns I want it to kinda cover him but since it spawns right where he's standing it goes behind him, sorry if I couldn't explain well :?!

Any help would be appreciated :D!!

EDIT: Also if possible & you help me with my 1st thingy can you maybe tell me how to make "impact" prefab spawn a little higher or is that not possible? Because I want it to kinda spawn in the middle of his body not on the ground, haha :)... -- I did impoact thingy myself so this all good, thanks for help Aqutaerion & Carlzalph :)!!!

local x, y, z = inst.Transform:GetWorldPosition()
local impactfx = SpawnPrefab("impact")
impactfx.Transform:SetPosition(x, y, z)
impactfx.Transform:SetScale(2.5,2.5,2.5)

Thanks you :D!!!

Edited by SuperDavid
Link to comment
Share on other sites

11 minutes ago, Aquaterion said:

to put it behind I once tried this and it worked:


pufffx.Transform:SetPosition(x, y-0.1, z)

so maybe if you do +0.1 instead of -0.1 it should appear infront.

 

Thanks a lot Aquaterion, it worked, thank you :D!!!

Link to comment
Share on other sites

21 minutes ago, SuperDavid said:

Thanks a lot Aquaterion, it worked, thank you :D!!!

Something to note about going vertically is that the effect shifts rather quickly horizontally when viewing from a horizontal distance.

 

Which is to say the effect might be seen more to the left/right of the character when viewed from afar, and may 'uncover' your character if you are trying to hide the character.

 

Though 0.1 isn't much distance at all and the effect is very small when compared to having it up by 1.0.

Edited by CarlZalph
Forum dupe removal.
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...