Camera shake question

8bitninja8bitninja Member Posts: 367
edited April 2015 in Working with GS (Mac)

Does Anyone know a way to have the camera not only follow the main actor but also be able to shake when attacking enemies?
I know how to do each of these separately but not at the same time. Any help is appreciated, Thanks!

Comments

  • 8bitninja8bitninja Member Posts: 367

    I'm thinking maybe if I have a camera control actor with these rules. (When camera shake is true interpolate self-position-x to self-position-x+10 otherwise constrain self-position -x to player-position-x)

  • 8bitninja8bitninja Member Posts: 367

    The above attempted kind of worked but was a little glitchy. Any other ideas? Anyone?

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2015

    ..

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    @8bitninja said:
    The above attempted kind of worked but was a little glitchy. Any other ideas? Anyone?

    Try using camera rotation instead. Just kick the camera rotation a random amount between say -15 and 15. Then use some fancy interpolates and a timer to get it to rotate slightly past 0 and then settle back down to 0.

    Or after the camera rotation is kicked, you could use the following constrain behavior to bring it back to 0 with a springy action.
    Constrain Attribute: [scene.Camera.Rotation] To: [( scene.Camera.Rotation +(0- scene.Camera.Rotation )*1.5)*.9]

    Modify the numbers '1.5' and '.9' to suite your taste.

  • 8bitninja8bitninja Member Posts: 367

    @RThurman thanks! I'll give that a try.

  • RossmanBrothersGamesRossmanBrothersGames Member Posts: 659

    In a platformer I did it pretty easy moving up and down on the y coordinate

    Make an integer call it "shake" make it equal 1 or more depending on how intense you want the shake

    Here is a the code:

    When Shake is true

    Timer: Every 0.1 Secs

    Change attribute shake to shake * (-1)

    Change attribute cameraposition.y to cameraposition.y + shake

    This switches shake back and forth from -1 to 1 moving the camer up and down rapidly, works pretty well

  • 8bitninja8bitninja Member Posts: 367

    Thanks @RossmanBrothersGames Glad you jumped in. I was thinking of asking you directly because I know that Jump Jack does this quite well. So if I have a camera actor with its X position constrained to Player actor's X and then apply the shake only to the camera actor's Y position it should work. This sounds promising. I'll test this out later tonight and hopefully all is good. Thanks Guys!

  • RossmanBrothersGamesRossmanBrothersGames Member Posts: 659
    edited April 2015

    yep, that's why I did the y coordinate as well, it won't look right to use the x when the camera moves along that plane.

  • RossmanBrothersGamesRossmanBrothersGames Member Posts: 659
    edited April 2015

    also I realized my above code may be a little confusing since I used the word "shake" for two different attributes, you probably want to name them something different but I think you get the idea. Fore example
    When "camerashake" is true might be better

Sign In or Register to comment.