icantevenname Posted June 27, 2017 Share Posted June 27, 2017 The title's pretty self explanatory, what do I need in the projectile's prefab script for it to despawn after hitting something? Link to comment Share on other sites More sharing options...
. . . Posted June 28, 2017 Share Posted June 28, 2017 I think you can put " inst:Remove() " to get rid of it after it hit the entity Link to comment Share on other sites More sharing options...
icantevenname Posted June 28, 2017 Author Share Posted June 28, 2017 That's the weird thing, it's already there. local function onhit(inst, attacker, target) local impactfx = SpawnPrefab("impact") if impactfx ~= nil then local follower = impactfx.entity:AddFollower() follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0) if attacker ~= nil then impactfx:FacePoint(attacker.Transform:GetWorldPosition()) end end inst:Remove() end Should I put the mod here to get a better look at it? I've already done everything but this. Link to comment Share on other sites More sharing options...
. . . Posted June 28, 2017 Share Posted June 28, 2017 (edited) It seems you want to spawn a impact fx on the thing you hit, yes? Maybe this code will work better, hopefully . Spoiler local impact = SpawnPrefab("impact") local x, y, z = inst.Transform:GetWorldPosition() local x1, y1, z1 = target.Transform:GetWorldPosition() local angle = -math.atan2(z1 - z, x1 - x) impact.Transform:SetPosition(x1, y1, z1) impact.Transform:SetRotation(angle * RADIANS) impact.Transform:SetScale(2, 2, 2) EDIT: Also, did you try putting "impactfx:Remove()" instead of "inst:Remove()"? Edited June 28, 2017 by SuperDavid Link to comment Share on other sites More sharing options...
icantevenname Posted June 28, 2017 Author Share Posted June 28, 2017 Still nothing... Maybe something in the coding is contradicting it? cactusspine.lua Link to comment Share on other sites More sharing options...
. . . Posted June 29, 2017 Share Posted June 29, 2017 Oh wait, you want your item do despawn when it hits something? Well, I dunno much about how items work & stuff, but try this out, maaaybe it might work.. cactusspine.lua If it still doesn't work, maybe giving it finiteuses component then breaking it after it hits its target will remove it? Link to comment Share on other sites More sharing options...
icantevenname Posted June 29, 2017 Author Share Posted June 29, 2017 1 hour ago, SuperDavid said: Oh wait, you want your item do despawn when it hits something? Well, I dunno much about how items work & stuff, but try this out, maaaybe it might work.. cactusspine.lua If it still doesn't work, maybe giving it finiteuses component then breaking it after it hits its target will remove it? That did it! That was the one thing that was keeping me from uploading it to the Steam Workshop! Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now