☢☢ Stormys Cool Camera Field of View Code ☢☢... (a bit of maths that works)

StormyStudioStormyStudio United KingdomMember Posts: 3,989
edited November -1 in Working with GS (Mac)
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...

Comments

  • GamersRejoiceGamersRejoice Member Posts: 817
    I'm a fan. Thanks for the pointers. :)
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    Looks cool Jon! But I'm used to high quality of your games and templates :)
    After you add some nice graphics, this could be a really cool game, or a part of Dark Asylum (am I right about DA? ;) )
  • HoneyTribeStudiosHoneyTribeStudios Member Posts: 1,792
    That's a useful tip, cheers.

    Game looks like it'll be good too.

    But I'm more interested in the SFX. Where can I download those marvelous sounds ;)
  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    Where did you get your FIRE sound effects from? They are AWESOME! Is it actual pro studio Army recordings of guns?

    Nice work though, really gonna help a lot of people out!

    Ace
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    :-)

    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...
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Sure is neat, Jon; good one, and thanks. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • mynameisacemynameisace Hull, UKMember Posts: 2,484
    stormystudio said:
    :-)

    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...

    I've been gone for a couple of months but bad puns are still knocking around... I like it! Feels like I've not missed a day :)

    Ace
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    @Ace...nice to see a familiar face back on the forums...

    and yeah I know...bad pun... sort of..
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    very nice. I like this a lot!
  • quantumsheepquantumsheep Member Posts: 8,188
    That's a nice bit of code, mate - bookmarked :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    glad people like it...

    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...
Sign In or Register to comment.