StarmanUltra Posted August 8, 2015 Share Posted August 8, 2015 Based on all the code I've seen, every single projectile attack is based on launching a weapon you have in hand. Even monsters will equip their projectile item before attacking. The problem is, I want a projectile to shoot out regardless of what is in the character's hand. What I want to do is have the character's attack range set to inst.components.combat:SetRange(6, 2) so that attack attempts will be made at medium range, but the attack will miss unless you're in normal melee range. I then have a listener for inst:ListenForEvent("onmissother", rangedattack) that will trigger when the attack fails. It will allow me to execute a normal melee attack, however. So, shouldn't my code be able to just spawn in a projectile, give it a trajectory based on my target, and launch? I've tried a bunch of things, but I'm running into all kinds of issues. SpawnPrefab("spit") doesn't seem to make it appear, even just staying in place, let alone trying to make it launch.Maybe there's some way to quick swap what's in the player's hands, execute the attack, then swap it back? But then it'd probably play all the equipping noises and that'd be annoying... Link to comment Share on other sites More sharing options...
DarkXero Posted August 8, 2015 Share Posted August 8, 2015 Like this?http://forums.kleientertainment.com/topic/53395-fist-projectile/The player has an option to right click a lot of stuff to cast a fireball to it. You can use the same logic to make your spit prefab a weapon and attach it to the ATTACK action function. Link to comment Share on other sites More sharing options...
StarmanUltra Posted August 9, 2015 Author Share Posted August 9, 2015 That's exactly what I needed! I had to modify the prefab spawn code a little since I'm calling it in character.lua, but it's functioning perfectly local function rangedattack(inst,data) local projectile = SpawnPrefab("spit") projectile:AddComponent("weapon") projectile.Transform:SetPosition(inst.Transform:GetWorldPosition()) projectile.components.projectile:Throw(inst, data.target)end 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