☢☢ Stormys Cool Camera Field of View Code ☢☢... (a bit of maths that works)
Evening world..
This may be simple maths for some, but its taken me a while to get it working.
Whilst working on my current project, I did some proper maths and it worked...probably the first time I've ever achieved any trig without googling or forum searching for it first.
THE SET UP
The game has a top down view point where you can move a character around by touching the screen on your beloved iPhone.
THE PROBLEM:
I had the camera control on the main actor, which meant at the very best the character was always going to be in the middle of the screen, so the distance to any on coming enemies was frustratingly close. Pretty standard problem with top down view points. And if this was a 3d setup you'd have the camera slightly behind the character to see whats going on (3rd person view point like in the Tomb Raider games for example)
THE ANSWER:
I needed to create a camera setup that would move the camera with the actor but keep in front of the actor and move around as they turn around. So even if the main character stands still and rotates around you can see a wider area of the stage. Make sense?
Anyway..My setup (Please feel free to improve on, its currently got too many contraints in for my liking)
I have my main actor with lots of rules on for all his movement.
Constrained his self.rotation to a game attribute game.angle
Also his position to:
game.Players_X
game.Player_Y
Then make a new actor 'Camera Controller'
add the normal 'Camera Control' behaviour to it.
Then constrain attribute:
self.Pos_x to game.Players_X +(cos( game.angle )*50)
self.Pos_y to game.Players_Y +(sin( game.angle )*50)
*Note: you could increase or decrease the *50 to what ever you need. * You might want to try interpolating to the offset only when the character is moving.
Heres a video showing what it looks like at the moment.

Hope it is of use to someone...
This may be simple maths for some, but its taken me a while to get it working.
Whilst working on my current project, I did some proper maths and it worked...probably the first time I've ever achieved any trig without googling or forum searching for it first.
THE SET UP
The game has a top down view point where you can move a character around by touching the screen on your beloved iPhone.
THE PROBLEM:
I had the camera control on the main actor, which meant at the very best the character was always going to be in the middle of the screen, so the distance to any on coming enemies was frustratingly close. Pretty standard problem with top down view points. And if this was a 3d setup you'd have the camera slightly behind the character to see whats going on (3rd person view point like in the Tomb Raider games for example)
THE ANSWER:
I needed to create a camera setup that would move the camera with the actor but keep in front of the actor and move around as they turn around. So even if the main character stands still and rotates around you can see a wider area of the stage. Make sense?
Anyway..My setup (Please feel free to improve on, its currently got too many contraints in for my liking)
I have my main actor with lots of rules on for all his movement.
Constrained his self.rotation to a game attribute game.angle
Also his position to:
game.Players_X
game.Player_Y
Then make a new actor 'Camera Controller'
add the normal 'Camera Control' behaviour to it.
Then constrain attribute:
self.Pos_x to game.Players_X +(cos( game.angle )*50)
self.Pos_y to game.Players_Y +(sin( game.angle )*50)
*Note: you could increase or decrease the *50 to what ever you need. * You might want to try interpolating to the offset only when the character is moving.
Heres a video showing what it looks like at the moment.

Hope it is of use to someone...
Comments
After you add some nice graphics, this could be a really cool game, or a part of Dark Asylum (am I right about DA?
Game looks like it'll be good too.
But I'm more interested in the SFX. Where can I download those marvelous sounds
Nice work though, really gonna help a lot of people out!
Ace
yeah the gun sound effects each cost around $199 per bang.
But I figured they were worth it..people always say they want more bang for their buck...
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Ace
and yeah I know...bad pun... sort of..
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Spent a bit of tonight working on a flame thrower idea using particles...have'nt quite mastered the particles offset on the x and y...but I think a similar technique should work.
I want the particles to start a certain distance away from the main character but at the moment the offset is ignoring his rotation, (the actual direction of the particles works just not the offset).
I guess I could have an invisible actor constrained to the dude like the camera and have that produce the particles but that means more constraints...
I'll get there in the end...in the mean time spinning around with flames looks cool...