Hello, I've been working with the SWCK and it's very useful. However, I have not been able to make a VElement move position/rotate angle when I shoot the swep. Can someone please explain to me how to make this happen? Thanks.
--Mispelled construction by accident
How exactly do you want it to rotate? It mostly involves modifying self.VElements["yourspinningthing"].pitchyawwhateverthefuck
But depending on the type of movement you want you need to do different things.
Thanks for the reply, and I am making an explosive sniper; I need to make this magazine VElement to move upwards however many units and then back down to its original position when it is ready to shoot again. Thanks
You could make it so that the position of your magazine is a mathematical function of NextPrimaryFire().
Something like
<elementpos>.z = <normal position> - math.Clamp( .5 * (self:GetNextPrimaryFire() - CurTime() , 0, <upper limit>)
[QUOTE=DropDeadTed;44110085]You could make it so that the position of your magazine is a mathematical function of NextPrimaryFire().
Something like
<elementpos>.z = <normal position> - math.Clamp( .5 * (self:GetNextPrimaryFire() - CurTime() , 0, <upper limit>)[/QUOTE]
I used...
[CODE]
function SWEP:Think()
self.VElements["magazine"].pos.z = Vector(0.625, 8.725, 3.994) - math.Clamp( .5 * (self:GetNextPrimaryFire() - CurTime()), Vector(0.625, 8.725, 3.994), Vector(0.625, 8.725, 8.994))
end
[/CODE]
and returned me with...
[CODE]
[ERROR] lua/includes/extensions/math.lua:46: attempt to compare number with userdata
1. Clamp - lua/includes/extensions/math.lua:46
2. unknown - addons/m9k specialties/lua/weapons/m9k_etech25/shared.lua:104
[/CODE]
Help please?
[QUOTE=hkbaker;44120643]I used...
[CODE]
function SWEP:Think()
self.VElements["magazine"].pos.z = Vector(0.625, 8.725, 3.994) - math.Clamp( .5 * (self:GetNextPrimaryFire() - CurTime()), Vector(0.625, 8.725, 3.994), Vector(0.625, 8.725, 8.994))
end
[/CODE][/QUOTE]
math.Clamp is for numbers but you are trying to pass it two vectors.
The key is to use the thing I gave you as a z value in your vector
(or y or x value depending on how your model is set up)
[editline]3rd March 2014[/editline]
Since you're effectively isolating the z value you might as well just not deal with vectors at all. Take out the vector () stuff and get rid of the x and y values.
And do that to the vectors in the clamp too, like the guy above me said you can't do that.
This is what i have made for my "The Sawgun" Weapon ( available on the workshop )
[CODE]
function SWEP:Think() -- Called every frame
self:OnThink() --calls the OnThink function which controls the spinning of the blade
end
local SpinAng = 270
local Spinz = 90
local Spiny = 0
local SpinAngw = 0
local Spinzw = 0
local Spinyw = 90
function SWEP:OnThink()
if (CLIENT) then
if SawbladeRotate:GetBool() == true then
SpinAng = SpinAng + 1
Spinz = Spinz + 0
Spiny = Spiny + 0
SpinAngw = SpinAngw + 0
Spinzw = Spinzw + 0
Spinyw = Spinyw + 1
self.VElements["saw_blade"].angle.x = SpinAng
self.VElements["saw_blade"].angle.z = Spinz
self.VElements["saw_blade"].angle.y = Spiny
self.WElements["saw_blade"].angle.x = SpinAngw
self.WElements["saw_blade"].angle.z = Spinzw
self.WElements["saw_blade"].angle.y = Spinyw
end
elseif SawbladeRotate:GetBool() == false then return end
end
[/CODE]
Sorry, you need to Log In to post a reply to this thread.