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 » Scripters
Home Search
 

Re: Anyone know how to make the camera follow the mouse?

Previous Thread :: Next Thread 
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
07 Jan 2017 03:24 PM
Like in Mass Effect when you move the mouse, the camera rotates around? Idk what that's actually called so I'm having difficulty describing it.

You know? Look controls? Or something like that lol
Report Abuse
TextSoaked is not online. TextSoaked
Joined: 04 Sep 2015
Total Posts: 1040
07 Jan 2017 03:53 PM
Uhhh

You can use mouse.Hit as a movement point for the camera, and interpolate the camera instantaneously w/ the focus being the same point

although I'm not sure if it'll work or not


Report Abuse
TextSoaked is not online. TextSoaked
Joined: 04 Sep 2015
Total Posts: 1040
07 Jan 2017 03:54 PM
You can also have some invisible GUI elements in the sides of the screen that moves the camera when the mouse enters, but I'm not sure if that's what you're trying to do


Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
07 Jan 2017 03:56 PM
Well to be honest I thought the same thing too but I can already tell you that it would cause a huge problem right off the bat. If that were to be done, the camera moving would also move the mouse. It would just keep looping until things got so far out of hand I wouldn't be able to stop.


I was only asking because I feel like there should be a mouse event that detects which direction the mouse is moving on your mousepad.

It could have the same type of control as the thumbstick for the gamepad but I know there's no property for the mouse that does this. I was hoping someone might have found a way around this that I was unable to come up with.
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
07 Jan 2017 03:58 PM
Invisible gui elements, eh? Too much work but it does inspire a different idea. Using AbsolutePosition lol

Still not what I'm going for but if someone doesn't have any ideas for what I'd like to do then that could be a decent alternative.

Thank you for that lol
Report Abuse
TextSoaked is not online. TextSoaked
Joined: 04 Sep 2015
Total Posts: 1040
07 Jan 2017 03:59 PM
Oh, you can manually get the distance that of which the mouse is deviating from the center of the screen in terms of X, and Y; then calculate the acceleration of the camera based on the magnitudes and apply it to the camera's velocity via interpolation


Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
07 Jan 2017 04:04 PM
My brain just farted.
Report Abuse
TextSoaked is not online. TextSoaked
Joined: 04 Sep 2015
Total Posts: 1040
07 Jan 2017 04:08 PM
lol

I think the method I was thinking about is about the same as absolutepos


Report Abuse
troy96900 is not online. troy96900
Joined: 04 Mar 2010
Total Posts: 31
07 Jan 2017 04:09 PM
http://wiki.roblox.com/index.php?title=Mouse_Appearance

-- Lock mouse to center of the screen and hide it
local UserInputService = game:GetService("UserInputService")

UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
UserInputService.MouseIconEnabled = false

-- Change the player's camera to scriptable so it can be moved with code
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable

-- Bind function to when the mouse moves. If it moves left or right, adjust an angle variable which will be used later
local angle = 0
UserInputService.InputChanged:connect(function(inputObject)
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
if inputObject.Delta.x < 0 then--if mouse left side (i think)
--move camera here
elseif inputObject.Delta.x > 0 then--if mouse right side (i think)
--move camera here
end
end
end)

Report Abuse
troy96900 is not online. troy96900
Joined: 04 Mar 2010
Total Posts: 31
07 Jan 2017 04:10 PM
nvm this wouldnt rrly work for what ur doing
Report Abuse
OAuth2 is not online. OAuth2
Joined: 27 Nov 2016
Total Posts: 751
07 Jan 2017 04:21 PM
Like this?
https://www.roblox.com/games/576845188/idek-tbh

I don't really know what you are talking about. Provide a video, maybe?


Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
08 Jan 2017 01:54 PM
Shouldn't be hard to get it. You know, like when you lock first person view and you move the mouse, the camera moves?

I'm looking for that, but in 3rd person. I've never really learn much about cameras since I never really bother with them.
Report Abuse
troy96900 is not online. troy96900
Joined: 04 Mar 2010
Total Posts: 31
08 Jan 2017 02:31 PM
oh you mean like this

https://www.roblox.com/games/51591654/Character-Testing
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
08 Jan 2017 06:40 PM
I don't know. I can't enter the game due to permissions.
Report Abuse
OAuth2 is not online. OAuth2
Joined: 27 Nov 2016
Total Posts: 751
08 Jan 2017 08:31 PM
http://wiki.roblox.com/index.php?title=API:Class/UserInputService/MouseBehavior

Unfortunately, doing this will not work until you replace the default CameraScript.
My way of doing this is just adding a LocalScript named "CameraScript" and do it from there.


Report Abuse
LilMcManiac is not online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
08 Jan 2017 08:34 PM
Im almost positive, mouse.X and mouse.Y return in pixels/offset, right?

So you maybe, could check the distance from the middle of the screen, 0. and if they are a good 30 pixels to the left or right, rotate the camera. Also, check the mouse.X, because thats horizontal.
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
08 Jan 2017 08:36 PM
mouse delta?

i tried doing fps mouselook but failed so idk


#code self = nil
Report Abuse
LilMcManiac is not online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
08 Jan 2017 08:38 PM
You could go off of this.


local mouse = game.Players.LocalPlayer:GetMouse();
while wait() do
if mouse.X < 500 then
print('left | '..mouse.X)
elseif mouse.X > 500 then
print('right | '..mouse.X)
end
end
Report Abuse
LilMcManiac is not online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
08 Jan 2017 08:48 PM
I think this might be what your looking for,

local cam = workspace.CurrentCamera;
local mouse = game.Players.LocalPlayer:GetMouse();
while wait() do
if mouse.X < 500 then
print('left | '..mouse.X)
cam.CoordinateFrame = cam.CoordinateFrame*CFrame.Angles(0,.01*mouse.X/1000,0)
elseif mouse.X > 500 then
print('right | '..mouse.X)
cam.CoordinateFrame = cam.CoordinateFrame*CFrame.Angles(0,-0.01*mouse.X/1000,0)
end
end
Report Abuse
OAuth2 is not online. OAuth2
Joined: 27 Nov 2016
Total Posts: 751
08 Jan 2017 09:01 PM
I would use mouse delta tho. It's more efficient in my pov.


Report Abuse
Geomonlover is not online. Geomonlover
Joined: 06 Dec 2013
Total Posts: 1
23 Aug 2017 10:44 PM
im wondering the same thing, and where do i place this? i hate having to use my right clicking button
Report Abuse
JemZem is not online. JemZem
Joined: 18 Jun 2017
Total Posts: 11
22 Sep 2017 08:45 PM
LilMcManiac your script works perfectly except that the more your mouse is further to the left, the slower the camera will move. This is because the value of mouse.X lowers as the mouse moves to the left. What I did was use y = 2/x, as X gets larger, y gets smaller and vice versa. Here's part of the script:

while wait() do
if mouse.X < 600 then
print('left | '..mouse.X)
local move = 4/mouse.X
cam.CoordinateFrame = cam.CoordinateFrame*CFrame.Angles(0,move*1.5,0)
end

local move acts as y and mouse.X substitutes x, I also changed the 2 to a 4 because the camera moved too fast
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
03 Oct 2017 10:00 AM
It's a good idea but the idea behind the post was to lock the cursor to the screen and simply move the camera in the same manner as if you held down the right mouse button, but looking back at some of the mouse properties it seems that you can offset your camera from the humanoid so actually using the cursor lock option and then changing the offset of the camera would essentially accomplish the same results.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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