playMaker

Author Topic: Camera Zoom from Speed  (Read 4823 times)

VectorF22

  • Junior Playmaker
  • **
  • Posts: 50
Camera Zoom from Speed
« on: October 19, 2012, 10:26:46 PM »
Hi,

I'm creating a 2d platform game using an orthographic camera.

I have the camera setup to smooth follow the character using an iTween Move Update which works just fine, but I'd really like the camera to smooth zoom out and back in dependent on the speed the character is moving...

I'm using the Set Property action to set the camera 'size' (giving the illusion of zooming) but I cant get it to work smoothly from the 'Get Speed' action on the character. I've tried using an Ease Float action, but unfortunately that doesn't update every frame... I don't know of any way you can smooth a float variable on the fly.

Any help you guys could give me would be amazing! Thanks!

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Camera Zoom from Speed
« Reply #1 on: October 20, 2012, 05:44:23 AM »
eh, that would be exactly how it's done. Ease float should have an option called "Every frame".
Otherwise you could probably just use Set Property directly every frame. No need for an ease float here, since the speed is probably growing gradually, right?
Best,
Sven

VectorF22

  • Junior Playmaker
  • **
  • Posts: 50
Re: Camera Zoom from Speed
« Reply #2 on: October 20, 2012, 06:48:43 AM »
Thanks for the reply!

I thought it would be how it's done too lol. Nope, 'Ease Float' doesn't have an every frame option. https://hutonggames.fogbugz.com/default.asp?W567

It runs once every time the state is called. I've tried making two states that loop into each other calling the ease every time, but that only equates to once every second rather than something that feels fluid and on the fly.

Having the 'set property' run every frame to the speed of the character was the first thing I did, but it doesn't work well at all. Essentially my character is a bouncing ball so it needs some kind of buffer or engine in the background to run smoothly...

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Camera Zoom from Speed
« Reply #3 on: October 20, 2012, 07:47:15 AM »
EDIT: try updating your version of playmaker
« Last Edit: October 20, 2012, 07:49:49 AM by kiriri »
Best,
Sven

VectorF22

  • Junior Playmaker
  • **
  • Posts: 50
Re: Camera Zoom from Speed
« Reply #4 on: October 20, 2012, 07:59:30 AM »
Hi Kiriri,

The .cs file you've sent me is exactly the same as the one I currently have which doesn't have an every frame function... You've given me an amazing idea to try and copy the 'every frame' function from another .cs file though!! Thanks :)
« Last Edit: October 20, 2012, 08:09:47 AM by VectorF22 »

VectorF22

  • Junior Playmaker
  • **
  • Posts: 50
Re: Camera Zoom from Speed
« Reply #5 on: October 20, 2012, 08:10:59 AM »
I'm already running the latest version.

VectorF22

  • Junior Playmaker
  • **
  • Posts: 50
Re: Camera Zoom from Speed
« Reply #6 on: October 20, 2012, 08:22:24 AM »
I've just realised I have no idea what im doing lol... I'm trying to add the 'every frame' code into the EaseFloat.cs but I can't get it to show in unity....

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Camera Zoom from Speed
« Reply #7 on: October 20, 2012, 08:57:41 AM »
try that one instead of your current one?
I'm sorry, I changed a lot of stuff in some of the base files, so it's hard to notice what is in the public build of playmaker, and what I did myself :S

If that didn't work, then I don't know what would... I used ease float hundreds of times already, and it always works every frame...
« Last Edit: October 20, 2012, 09:03:18 AM by kiriri »
Best,
Sven

VectorF22

  • Junior Playmaker
  • **
  • Posts: 50
Re: Camera Zoom from Speed
« Reply #8 on: October 20, 2012, 09:37:49 AM »
That's worked perfectly!! Thankyou!!!

It's also added an every frame function to the ease vector3 action, but it doesn't work on there for some reason... (It still only updates the once rather than every frame). I don't suppose you could send me your EaseVector3.cs too?

Thanks again kiriri!

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: Camera Zoom from Speed
« Reply #9 on: October 20, 2012, 09:53:57 AM »
I've looked at it, and it's getting ridicolius :D I mean, the every frame option is just a dummy, I never finished it, but since I worked on it and it apparently worked on the ease float, I must've changed something useful... If only I knew what that was... I'll see if I can find it again, but this'll probably take sometime as I don't really know what I'm looking for... Maybe you can ease the individual dimensions (x, y , z) of your vector for now each as floats... while I try to see where the difference is.
Best,
Sven

VectorF22

  • Junior Playmaker
  • **
  • Posts: 50
Re: Camera Zoom from Speed
« Reply #10 on: October 20, 2012, 10:00:08 AM »
It's funny you should say that.... I turned off the 'every frame' function and it still worked lol... Either way, great job on getting the float to work! but yeah, if you could get the ease vector3 to work in the same way then that would be an absolute god send!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Camera Zoom from Speed
« Reply #11 on: October 22, 2012, 03:44:22 AM »
hi,

 I worked on Hotween and I made actions to tween all fsm variables, you should check it out, you can even tween strings :)

http://hutonggames.com/playmakerforum/index.php?topic=2299.0

 bye,

 Jean