Charas-Project

Game Creation => Requests => Topic started by: fruckert on November 12, 2012, 02:54:30 AM

Title: MATH!!1!
Post by: fruckert on November 12, 2012, 02:54:30 AM
So, I've been working on a game lately, and my tiny bit of production has been halted by a math problem.
It's a first person game, and I'm experimenting with the camera controls, doing a Metroid Prime like control scheme, wherein the closer the mouse is to the edge of the screen, the faster the camera rotates...after it's out of bounds of a bounding box, that is. That part's important, mind you.
So, here's what I'm trying to do:
I have a rectangle representing the bounding box, which is computed from a single float (0.0 -> 1.0) telling how much of the screen it covers.
After the mouse leaves the rectangle, I want to find out the coordinates where a ray going from the center of the screen to the mouse would intersect on both the bounding box and the edge of the screen.
I would then do some magic on those coordinates that isn't important, and then that result will be applied to camera rotation.

Does anybody at all have any idea on how to do this?
Title: Re: MATH!!1!
Post by: Meiscool on November 12, 2012, 03:35:38 AM
Is the bounding box and a ray a necessity? Seems to me that a simple formula of X </> Specified value causes direct increase in camera movement, and as X value gets farther away from Specificed value, camera movement increases as well. I would do proportions, such as (if mouse is far right of screen), Mouse X - Bounding X, Square value/100, add to camera movement speed with cap of Z.

Or can you not do that?
Title: Re: MATH!!1!
Post by: fruckert on November 12, 2012, 03:42:41 AM
I tried that and it felt jerky and off.
I think the vector math might make it a bit smoother, due to more accuracy.
Don't know until I actually get it done, though.

Also, I should note that the game is in first person, and in Unity.
Title: Re: MATH!!1!
Post by: fruckert on November 12, 2012, 11:04:37 PM
Instead of the crazy complicated box ****, I opted for a relatively simple circle based solution instead, at Osmose's suggestion.
It works a lot better.

After I get some actual work done on this project, I'll post a thread, but right now all I have is a capsule moving around and looking at a terrible grey brick landscape.
Title: Re: MATH!!1!
Post by: drenrin2120 on November 15, 2012, 04:29:09 AM
Woo! Grey brick landscape!
Title: Re: MATH!!1!
Post by: fruckert on November 15, 2012, 04:42:13 AM
And toon shaded box gun that doesn't shoot anything!