Evsey Posted June 3, 2019 Share Posted June 3, 2019 I am making a weapon that fires projectiles, and I want the projectiles to hover above ground like blowdarts, but when I fire my projectiles - they simple slide along the ground. How do I achieve the flying effect that blowdarts have? Something I considered is setting the Y of the projectile to something like 1.5, but then it won't collide properly with the target, since everything has a Y of 0, and gravity would affect the projectile. Here is my current code: local assets={ Asset("ANIM", "anim/rpgprojectile.zip"), } prefabs = {} local function onthrown(inst, data) inst.AnimState:SetOrientation(ANIM_ORIENTATION.OnGround) inst.AnimState:PlayAnimation("idle") local x,y,z = inst.Transform:GetWorldPosition() inst.Transform:SetPosition(x,1.5,z) end local function fn() local inst = CreateEntity() local trans = inst.entity:AddTransform() local anim = inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank("rpgprojectile") inst.AnimState:SetBuild("rpgprojectile") inst.AnimState:PlayAnimation("idle") MakeInventoryPhysics(inst) RemovePhysicsColliders(inst) if not TheWorld.ismastersim then return inst end inst:AddComponent("projectile") inst.components.projectile:SetSpeed(30) inst:ListenForEvent("onthrown", onthrown) inst.components.projectile:SetOnHitFn(inst.Remove) inst.components.projectile:SetOnMissFn(inst.Remove) inst:AddComponent("explosive") inst:AddTag("NOCLICK") return inst end return Prefab("rpgprojectile", fn, assets, prefabs) Link to comment Share on other sites More sharing options...
s1m13 Posted June 4, 2019 Share Posted June 4, 2019 (edited) I guess inst.AnimState:SetOrientation(ANIM_ORIENTATION.OnGround) is wrong. Have a look at all the other Options of ANIM_ORIENTATION. There are several others which are not "OnGround". Is there a reason, you used OnGround? Only a guess Edited June 4, 2019 by s1m13 Link to comment Share on other sites More sharing options...
Evsey Posted June 4, 2019 Author Share Posted June 4, 2019 Do you know where I can view all other ANIM_ORIENTATION options? Also, the reason I used OnGround is because the blowpipe prefab uses that. Link to comment Share on other sites More sharing options...
Evsey Posted June 4, 2019 Author Share Posted June 4, 2019 By doing for key,value in pairs(ANIM_ORIENTATION) do print(key,value) end I have seen that there are only a few other animation orientations (Default, Billboard, OnGroundFixed) I assume that the default one is the one that happens when you dont set an orientation, so it doesn't work. I tried Billboard, and it didn't give me the desired effect either. OnGroundFixed didn't give the desired effect either, since the projectile needs to be looking in the direction of the target. Link to comment Share on other sites More sharing options...
s1m13 Posted June 6, 2019 Share Posted June 6, 2019 (edited) OnGround seems to be right, if blowdarts use it aswell. I always start a mod by copying another prefab (in this case blowdart) and repeat changing stuff while everything is correct - in small steps. Maybe start over and try again with blowdart.lua ... Edited June 6, 2019 by s1m13 Link to comment Share on other sites More sharing options...
Evsey Posted December 13, 2020 Author Share Posted December 13, 2020 I've solved this issue - the blowdarts are flying above the ground because they have their y set to 2, along with an increased hitbox to accomodate for the hovering. Setting the launch offset for the projectile to be above the ground, along with increasing the hitbox, gave me the same effect. This is the two lines needed to make it work: inst.components.projectile:SetLaunchOffset(Vector3(0, 2, 0)) inst.components.projectile:SetHitDist(2) 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