vanclan117 Posted July 17, 2015 Share Posted July 17, 2015 I'm new to modding and I am working on making a weapon that allows the owner to dash while using it but I have no idea on how to do it or where to start. I have some ideas on what could make a pseudo-dash such as increasing the movementspeed of the character to a really high amount when the character is higher than X feet away. If making a dash would not work, then I am open to having it teleport the user. I would like these to be when the person clicks to attack something and not targetable on the ground (to avoid spamming dashes/teleports to increase mobility). I have searched the forums and I have had no luck looking for what I'm trying to make. Thank you in advance for any help people give Link to comment https://forums.kleientertainment.com/forums/topic/56251-need-help-adding-a-dash-when-attacking-to-custom-weapon/ Share on other sites More sharing options...
Mobbstar Posted July 18, 2015 Share Posted July 18, 2015 For starters, you need a function that fires when the weapon is used local Dash = function(inst, wilson, target) --all following code, if not told otherwise, should go hereend --[...] local fn = function() --you already have this line--[...]inst:AddComponent("weapon") --you already have this (I hope)inst.components.weapon.onattack = Dash Teleporting is easier. Here's my absolutely untested concept. It uses a while loop too, which tend to freeze the game: local pos = wilson:GetPosition() --get current positionlocal pos2 = target:GetPosition() --get target positionlocal differ = pos - pos2 --the differences in coordinates --now, you need to calculate how forward you want the player to get tp'dlocal newpos = pos + (differ * 2) --twice the distancelocal repeat = true while repeat doif GetGroundTypeAtPosition(newpos) ~= GROUND.IMPASSABLE then --valid ground! yayrepeat = false --you can stop nowbreak --don't continue to the next bit eitherendnewpos = newpos - (differ / 10) --get closer to the target (eventually one would end up near the current position)end wilson.Transform:SetPosition(newpos.x,pos.y,newpos.z) --tp there (y is height, usually 0, and doesn't matter at all) Link to comment https://forums.kleientertainment.com/forums/topic/56251-need-help-adding-a-dash-when-attacking-to-custom-weapon/#findComment-655416 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