|
| 02 Aug 2014 09:16 PM |
| How would I make a player's arms (in angles) follow their mouse based on it's y axis? |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 02 Aug 2014 09:36 PM |
| I'm going to be perfectly honest here: I have absolutely no idea what you want help with. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2014 09:37 PM |
Just do something like:
arm.CFrame = CFrame.new(arm.Position, arm.Position + (mouse.Hit.p * Vector3.new(0, 1, 0) );
|
|
|
| Report Abuse |
|
|
|
| 02 Aug 2014 09:37 PM |
| When I'm zoomed in with my gun, I want my player's arms to look up and down (in angles) following the y axis of the mouse. I've tried everything, and I can't get it to work perfectly |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2014 09:40 PM |
Woops I messed up I think.
arm.CFrame = CFrame.new(arm.Position, arm.Position + ((mouse.Hit.p - arm.Position)* Vector3.new(0, 1, 0)) );
i don't even know, i can't think right now |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 02 Aug 2014 09:44 PM |
@cnt - If I recall correctly that script is going to give you problems because the Arm's position is at the center of the brick, rather than the joint's logical position. Also the front-surface of the arm isn't the bottom.
@OP
What was wrong with the script I gave you a few days ago?
local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:wait() local LeftArm = Character:WaitForChild("Left Arm")
Character.Torso["Left Shoulder"]:Destroy()
LeftArm.Anchored = true
while wait() do local JointPosition = Character.Torso.CFrame * CFrame.new(-1.5, .5, 0) local TargetPosition = Player:GetMouse().Hit.p LeftArm.CFrame = CFrame.new(JointPosition.p, TargetPosition) * CFrame.Angles(math.pi/2, 0, 0) * CFrame.new(0, -.5, 0) end |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2014 09:45 PM |
How would I convert that to angles? I'll show you what variables I'm using:
Motor1 is a motor for the player's right arm, Motor2 is a motor for the player's left arm,
RightArm is Moor1's C0, LeftArm is Motor2's C0.
This is what I'm doing. Keep in mind this works and I have this in a loop with clerp, but I need to know how to make the angle follow the mouse on it's y axis:
RightArm = CFrame.new(0.1,0.175,0.15) * CFrame.Angles(1.585 + Mouse.Y,0,0); LeftArm = CFrame.new(-0.825,0.35,-1.25) * CFrame.Angles(1.57 + Mouse.Y,0,0.4);
Not matter what I do with the mouse, the arms either point directly down, or barely even look up |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2014 09:46 PM |
| @swan, it moves the arm's angles to the mouse when it's at any position, when I only want it to follow the mouse's y position |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2014 09:46 PM |
'Also the front-surface of the arm isn't the bottom.' Really O_o? That's dumb I always thought it was. |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 02 Aug 2014 09:47 PM |
@cnt
The front-surface faces forwards the same direction as the Torso.
Because Roblox. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 02 Aug 2014 09:47 PM |
| Grrr that totally ruins my animation system I still haven't tested... |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2014 09:48 PM |
Step 1: Get the vector from the shoulder to the mouse:
local vec = (MOUSE.Hit.p - TORSO.Position - Vector3.new(0, -0.5, 0)).unit
Step 2: Do math
local angle = math.asin(vec)
Step 3: Set C1 to said math
SHOULDER.C1 = CFrame.new(-0.5,0.5,0)*CFrame.Angles(angle,math.pi/2,0) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 02 Aug 2014 09:51 PM |
| Players.Player1.Backpack.Animation & Aiming:192: bad argument #1 to 'asin' (number expected, got userdata) |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2014 09:53 PM |
@nice, I used your script, and it makes the arm point down when I look up, even when I changed -0.5 to 0.5 (I'm using C0)
This is what I tried, but it makes the arm super bouncy, constantly moving up and down when looking up:
RightArm = CFrame.new(0.1,0.175,0.15) * CFrame.Angles(1.585 + math.rad(Mouse.Hit.Y/50),0,0); LeftArm = CFrame.new(-0.825,0.35,-1.25) * CFrame.Angles(1.57 + math.rad(Mouse.Hit.Y/50),0,0.4); |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Aug 2014 10:04 PM |
local vec = (MOUSE.Hit.p - TORSO.Position - Vector3.new(0, -0.5, 0)).unit local angle = math.asin(-vec.Y) SHOULDER.C1 = CFrame.new(-0.5,0.5,0)*CFrame.Angles(angle,math.pi/2,0)
? |
|
|
| Report Abuse |
|
|
|
| 02 Aug 2014 10:07 PM |
| Same result. It's facing down no matter what, and doesn't look up half way. |
|
|
| Report Abuse |
|
|
| |
|