generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: mouse

Previous Thread :: Next Thread 
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
02 Aug 2014 09:17 PM
bump
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
02 Aug 2014 09:19 PM
getb
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
02 Aug 2014 09:23 PM
fddevb
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
02 Aug 2014 09:25 PM
mouse
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
02 Aug 2014 09:35 PM
gg
Report Abuse
swmaniac is not online. 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 is not online. 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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
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 is not online. 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 is not online. 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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
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 is not online. 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 is not online. 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 is not online. 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
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Aug 2014 09:50 PM
lol asin(vec)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Aug 2014 09:50 PM
vec.Y*
I'm dumb.
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
02 Aug 2014 09:51 PM
Players.Player1.Backpack.Animation & Aiming:192: bad argument #1 to 'asin' (number expected, got userdata)
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
02 Aug 2014 10:00 PM
bump
Report Abuse
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
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
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
02 Aug 2014 10:07 PM
Same result. It's facing down no matter what, and doesn't look up half way.
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
02 Aug 2014 10:14 PM
bump
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image