Charas-Project

  • Home
  • Help
  • Search
  • Calendar
  • Login
  • Register
*
Please login or register.

Login with username, password and session length
 

News:

Click here to join us on IRC (#charas on irc.freenode.net)!



  • Charas-Project »
  • Game Creation »
  • Requests »
  • MATH!!1!
« previous next »
  • Print
Pages: [1]

Author Topic: MATH!!1!  (Read 4418 times)

Offline fruckert

  • Star-Star-Star-Star
  • Sage
  • *
  • Posts: 8,148
  • Not intended for public consumption
MATH!!1!
« 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?
Logged
Quote
Ellie: I had a slice of ham in my hand. I was going to drop it, so I slapped it hard. It attached itself to the wall

Offline Meiscool

  • Staff
  • Exemplar
  • *
  • Posts: 1,138
  • I died for YOUR sins.
Re: MATH!!1!
« Reply #1 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?
Logged

Offline fruckert

  • Star-Star-Star-Star
  • Sage
  • *
  • Posts: 8,148
  • Not intended for public consumption
Re: MATH!!1!
« Reply #2 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.
Logged
Quote
Ellie: I had a slice of ham in my hand. I was going to drop it, so I slapped it hard. It attached itself to the wall

Offline fruckert

  • Star-Star-Star-Star
  • Sage
  • *
  • Posts: 8,148
  • Not intended for public consumption
Re: MATH!!1!
« Reply #3 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.
Logged
Quote
Ellie: I had a slice of ham in my hand. I was going to drop it, so I slapped it hard. It attached itself to the wall

Offline drenrin2120

  • Global Moderator
  • Sage
  • *
  • Posts: 6,101
Re: MATH!!1!
« Reply #4 on: November 15, 2012, 04:29:09 AM »
Woo! Grey brick landscape!
Logged

Offline fruckert

  • Star-Star-Star-Star
  • Sage
  • *
  • Posts: 8,148
  • Not intended for public consumption
Re: MATH!!1!
« Reply #5 on: November 15, 2012, 04:42:13 AM »
And toon shaded box gun that doesn't shoot anything!
Logged
Quote
Ellie: I had a slice of ham in my hand. I was going to drop it, so I slapped it hard. It attached itself to the wall

  • Print
Pages: [1]
« previous next »
  • Charas-Project »
  • Game Creation »
  • Requests »
  • MATH!!1!
 

  • SMF 2.0.10 | SMF © 2015, Simple Machines
  • XHTML
  • 2O11
  • RSS
  • WAP2
  • Simple Machines Forum