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: Improvements to Cameras (for FPS games)

Previous Thread :: Next Thread 
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
08 Mar 2013 10:43 AM
So the other day I was playing a game on roblox (whoa, right?) and I noticed that using guns in first person mode is pretty tough. Especially when zoomed in, a single pixel's movement of the mouse moves the cursor a significant distance. You can quickly move from the left side of your target's head to the right with no area in-between.

I set out to fix it and came up with this result.
http://www.roblox.com/--place?id=22930586
My first goal was to replicate the first person camera (where the mouse always stays in the center), but that was stopped by the fact that I can't set the mouse's x and y coords.
This was the next best thing I came up with. You right click to start panning the camera, it pans in the direction your mouse has moved from the start position, and the camera motion stops when you release the mouse button.

My result wouldn't be easy to use in an actual first person shooter game. However, it still lets you control the crosshair in the center very finely. If you go to the place, you can test it out by sniping the zombies on the island about 1100 studs away (q with tool selected to zoom in). You can also compare it to the standard first-person, custom-type camera.


I'm hoping a few of you guys could be interested in this and try and make your own. I made that one with the scriptable camera type because it was a clean slate, but I think to get better results you need to get hacky with the different camera types.

And if anyone has any advice you could give me to achieve better camera controls, let me know. Finding a way to keep the mouse in the center and still know by how many pixels it's being moved would solve this, so tell me any relevant hax.
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
08 Mar 2013 10:45 AM
Going to test this right now :)
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
08 Mar 2013 10:52 AM
Great demo. However, even though you can't set the mouse position, it would be nice for the camera to only move when you move the mouse. Continuous movement is difficult to use. Also a sensitivity option which scales with the zoom.
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
08 Mar 2013 10:55 AM
Yeah, I considered that, but if you wanted to spin around, you'd have to do a few mouse strokes. I'll take a look at that in studio and see how it works.
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
08 Mar 2013 11:08 AM
certainly a start, aiming at that distance would be nearly impossible with standard camera controls, but with this it's pretty easy.
Report Abuse
Wikidata is not online. Wikidata
Joined: 03 Mar 2013
Total Posts: 24
08 Mar 2013 11:49 AM
really neat.
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
08 Mar 2013 11:51 AM
Neato. I tried to modify to work with LockFirstPerson and to work without needing to hold mouse2, but I kinda completely broke it.

http://www.roblox.com/blobby-island-cursor-thing-place?id=38222988

It also doesn't help that making the camera "Custom" for a frame causes it to jerk backwards. :/
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
08 Mar 2013 12:50 PM
I tried making the camera type custom so that I could keep the mouse in the center. I had planned to just undo all camera movements and replace them with my own. It ended up in some weird scenario where a) the screen was always white and b) zooming in to first person caused the character to die. REALLY have no idea where that second one comes from.
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
08 Mar 2013 12:56 PM
I know, right?

I wish first person mode worked for scriptable cameras.
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
08 Mar 2013 12:59 PM
As for not requiring the right mouse button and allow to recenter the view, would periodically forcing a zoom in by returning to the default Camera type, CFraming in the camera, then returning to Scriptable, and then returning the camera to where it was before work? If you do it all in the same frame, I don't think that there will be a noticable jump in the camera, but I'm not certain whether or not if you do it in one frame it will move the cursor.
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
08 Mar 2013 01:11 PM
^ that's what I did

I ran into a few problems. biggest one is that the script thought the mouse moved every time it was reset and nothing I was doing seemed to work, so I eventually just cancelled out mouse motion when magnitude < 10. That kinda works if the mouse isn't moving really fast, but it's not a real fix to the problem.

Also, setting the camera back to Custom causes it to refocus on the head, and it has an arbitrary offset between -0.2,0,0 and -0.4,0,0 so it jerks around. I tried cancelling it out by adding the offset to the scriptable position, but that didn't do anything. Cameras are weird.

Also I uncopylocked my version. I meant to do that when I posted but I forgot.
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
08 Mar 2013 02:24 PM
@BlueTaslem
That was exactly the kind of hax I was looking for! I'll try and implement that later. Hopefully it doesn't have a flicker associated with it.
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
09 Mar 2013 12:22 PM
Ok, thanks to BlueTaslem's suggestion I drastically improved this camera. I fixed up the code and rewrote it (because modifying a script 4 or 5 times always makes the code look like a mess). Most importantly, the transition when the mouse moves back to the center is unnoticeable as long as the mouse's icon is invisible.

The one function in there called "ModifyTilt" can be changed to reflect how you want the camera to pan and tilt. I used a quadratic relationship for less than 6 pixels and a linear relationship for more than 6 pixels, but that can be changed based on your own needs.


Here's the script.
http://www.roblox.com/Custom-First-Person-Camera-item?id=109009588
And it's also updated in the map.

I know it's a pain to look at the source code of models, so I'll post it here if someone PMs me and tells me how to retain all the tabs, haha.
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
09 Mar 2013 12:44 PM
First of all, beautiful, that's a great improvement. To fix the character rotating slowly you can quite easily stick a CFrame update into a super fast loop. This loop will either be activated by..

Workspace.CurrentCamera.Changed
Mouse.Idled
Mouse.Moved (You'll have to use Mouse.Moved and Mouse.Idled in conjunction).

The main problem with aim-down the sight guns is I'm not sure how to proceed in aligning all four CFrames of the gun (or 3 if you only use 1 part to dictate the position of the gun). However, I'm sure it's fairly simple if I spend enough time experimenting.

It would be cool if you made a framework for first person guns, even just to calculate the position that a weld needs to be in to get a gun barrel to align with the camera, and to position the character's hands and whatnot.

Second of all, viewing the source model of models is easier than places:

t.co/ddKwKGdTCR

Use the ROBLOX Asset widget (Not made by me, mind you), and downloading models is never more to be a pain.

Finally, retaining tabs is already done, if I remember correctly. Just copy and paste (or even, drag) the highlighted text into a text editor, and HTML formatting will magically disappear.


Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
09 Mar 2013 04:42 PM
"To fix the character rotating slowly"
I don't see what you're talking about here.

And while I made this script for guns, I have no intention to make a more advanced framework. I've got all these projects I'd rather do. This was just supposed to be a short break.
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
09 Mar 2013 05:08 PM
I noticed that you can move the mouse real fast to escape the buffer. Adding

BUFFER_SIZE = math.max(math.max(x,y) * 20, 150)

to the end of ModifyTilt fixed that for me.
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
09 Mar 2013 05:15 PM
Also, is there any particular reason why I can't press esc to access the game menu? How does that even get blocked?
Report Abuse
Prehistoricman is not online. Prehistoricman
Joined: 20 Sep 2008
Total Posts: 12490
09 Mar 2013 05:20 PM
^
I sense exploitability :D

But you can't lock the mouse so... hmm
Report Abuse
Quenty is not online. Quenty
Joined: 03 Sep 2009
Total Posts: 9316
09 Mar 2013 06:38 PM
I love the esc key and the little menu icon for ROBLOX games. I hate the playerlist that is stuck in the corner, the fact chat is anchored to the corner, and most of the other buttons.

I can work around a small button in the corner, but the rest of the UI is invasive. But enough complaining about the UI.

In any event, your framework is cool. Also, when I said the character rotating smoothly, the problem is when you create a gun, and you want to aim down the sights of the gun, the character rotates slower then the camera, even in first person mode.

This means the gun isn't always centered in the screen. To counter it, you basically stick it in a fast update loop. :)

Anyway, great thread.
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
10 Mar 2013 12:37 AM
"I noticed that you can move the mouse real fast to escape the buffer"
Yeah, I tried to strike a balance. I want to avoid having to move the camera back to first person mode as often as I can, but I want to prevent people from accidentally going out of the buffer. I landed on 150 pixels by trial and error. In comparison to 50 and 100, I very rarely went out of the screen unintentionally.
That can be increased to 200 or 250 to pretty much guarantee that the buffer won't be exceeded, but that might be a little unnecessary. The only thing to make sure of is that 2 * BUFFER_SIZE is still at least 100 less than the screen's size in either direction.

"Also, is there any particular reason why I can't press esc to access the game menu? How does that even get blocked?"
I have no idea why that happened. I'm using a scriptable camera type--that's about it.
If I ever make a game, I'll have to figure out a way to get that esc menu to show up, and maybe add my own support for modal Guis so the mouse can move freely.

And Quenty, I actually made 0 effort to have the gun center in the screen, haha. I just wanted to include a zoom so you could actually see the zombies you were shooting at.
Report Abuse
NinjaShadow1 is not online. NinjaShadow1
Joined: 03 Mar 2009
Total Posts: 2689
17 Mar 2013 02:50 PM
Anyone edit this to use only one camera object yet? I've tried but I don't know too much about how the Camera behaves and it keeps bugging out.
Report Abuse
NinjaShadow1 is not online. NinjaShadow1
Joined: 03 Mar 2009
Total Posts: 2689
17 Mar 2013 06:03 PM
Here's my latest attempt:
http://www.roblox.com/Camera-Test-place?id=19824676

Also, by setting Player.CameraMode to LockFirstPerson I fixed the core gui
Report Abuse
NinjaShadow1 is not online. NinjaShadow1
Joined: 03 Mar 2009
Total Posts: 2689
17 Mar 2013 06:06 PM
Quick warning. That is an amazingly messy edit of blobby's script.
Report Abuse
HaxHelper is online. HaxHelper
Joined: 19 Dec 2009
Total Posts: 1208
17 Mar 2013 10:16 PM
I'm still hoping for a complete mouse overhaul, which appears to be in the works.
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