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: How would I make/rotate a natural first person camera?

Previous Thread :: Next Thread 
LifeInDevelopment is not online. LifeInDevelopment
Joined: 10 Nov 2015
Total Posts: 670
19 Mar 2017 01:10 PM
I've tried to put the camera inside the head and make the camera point to mouse.Hit.p but thats extremely buggy, I dont like using firstpersonlock because I want to make something more natural for my game? What would be the process to make this?
Report Abuse
RoyStanford is online. RoyStanford
Joined: 21 Oct 2008
Total Posts: 2222
19 Mar 2017 01:21 PM
Change camera type to scriptable, and using renderstepped event update it's cframe to be inside the player's head, however don't mess with the rotation yet.

Keep track of it's current rotation in the script using variables, and whenever the mouse is moved just update the rotation's accordingly. So it'll look something like this:

local x,y = 0,0,0

renderstepped:connect(function()
cam.CFrame = head.CFrame * CFrame.Angles(0,y,0) * CFrame.Angles(x,0,0)
end)

And then use the userinput changed event to update the x and y variables whenever the mouse moves

http://wiki.roblox.com/index.php?title=API:Class/UserInputService/InputChanged
Report Abuse
RoyStanford is online. RoyStanford
Joined: 21 Oct 2008
Total Posts: 2222
19 Mar 2017 01:23 PM
That's just the general idea, you'll have to play with the specifics. However, I did make a mistake. Don't use the head cframe, use it's position instead so the rotation based on the variables will always be the same

cam.CFrame = CFrame.new(head.Position)--then rotate
Report Abuse
Real_Spooky is not online. Real_Spooky
Joined: 23 Oct 2013
Total Posts: 3149
19 Mar 2017 01:24 PM
Roy's solution is beautifully simple. The only other thing I'd add is analog stick support, too.
Report Abuse
LifeInDevelopment is not online. LifeInDevelopment
Joined: 10 Nov 2015
Total Posts: 670
19 Mar 2017 01:31 PM
thanks, im assuming i have to use mouse.Move to get these x and y variables?
Report Abuse
RoyStanford is online. RoyStanford
Joined: 21 Oct 2008
Total Posts: 2222
19 Mar 2017 01:56 PM
No. Look at the link I provided, it explains how to do it there. Specifically, look at the printMovement function.
Report Abuse
LifeInDevelopment is not online. LifeInDevelopment
Joined: 10 Nov 2015
Total Posts: 670
19 Mar 2017 02:09 PM
Oh i see it, thanks.
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