icantevenname Posted October 24, 2021 Share Posted October 24, 2021 I wanna give a modded character basically a sniper rifle. I figure a good way to make the player play like a sniper is to make the weapon do damage based on how far away the player is from the target, up close would deal pitiful damage while as far as possible would deal the most damage. I can't even begin to think of anything similar to this that exists in the game, so if it can't be done, it won't be a big deal. Link to comment https://forums.kleientertainment.com/forums/topic/134707-damage-based-on-distance/ Share on other sites More sharing options...
Monti18 Posted October 24, 2021 Share Posted October 24, 2021 (edited) The easiest way is probably to set your damage as a function of the distance to the target. local function DistanceDamage(inst,attacker,target) local distsq = attacker:GetDistanceSqToInst(target) --get distance to target return 1 * distsq --return a value for the damage done end inst.components.weapon:SetDamage(DistanceDamage) This is just an example, change it to your liking. Edited October 24, 2021 by Monti18 1 Link to comment https://forums.kleientertainment.com/forums/topic/134707-damage-based-on-distance/#findComment-1507071 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