playMaker

Author Topic: Smooth Camera 2D Follow?  (Read 2989 times)

RadSoft

  • Playmaker Newbie
  • *
  • Posts: 2
Smooth Camera 2D Follow?
« on: May 06, 2017, 01:05:47 PM »
Hello World!

I'm just trying to make my camera follow my character in the Y axis basically when my player reaches a specified height it must follow the player, only if it's positive (upwards)

I'm trying to achieve this in PlayMaker well this is the original script itself:



This is what I have so far:


and this is the FollowPlayer state:


The issue that I'm having, is that I don't know what I've missed or where I have missed, that the camera simply won't move...

Any help is highly appreciated!
« Last Edit: May 06, 2017, 01:08:03 PM by RadSoft »

skipadu

  • Playmaker Newbie
  • *
  • Posts: 43
  • Learning continuously
    • serialkamikaze.itch.io
Re: Smooth Camera 2D Follow?
« Reply #1 on: May 06, 2017, 02:46:23 PM »
Hmm.. not sure but it looks like you are getting the Player.Position.Y and transY both from the player and they are highly probably always the same in your actions. Therefore, it doesn't ever send the FollowPlayer event in Float compare.

RadSoft

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Smooth Camera 2D Follow?
« Reply #2 on: May 06, 2017, 05:02:23 PM »
Hello,

Thanks for the input, any ideas how I could represent the original script into playmaker visual script? or how to improve my current work? As it seems you're correct I don't really know what would be the best approach towards this issue.

skipadu

  • Playmaker Newbie
  • *
  • Posts: 43
  • Learning continuously
    • serialkamikaze.itch.io
Re: Smooth Camera 2D Follow?
« Reply #3 on: May 07, 2017, 02:32:26 AM »
I have a test setup that my player and camera have the same Y-position at the start.
When the player goes up the stairs it's Y-position will be then 2 and camera will move up by two. Then when player climbs more stairs and reaches Y-position of 4, the camera will again follow. If the player jumps off the stairs and Y-position will decrease, the camera won't move.


Little step by step of the actions:
I added FSM to Main camera.

State: Waiting for movement
Get Position - first we take player's Y-position
Get Position - then we take camera's Y-position, which is owner because FSM is in it.
Float Compare - Compare playerPosY to cameraPosY. I have set tolerance of 2, so that camera will not jump right away when starting the game.

State:Move the camera
Float Add - adds two (2) to cameraPosY variable
Set Position - Moves the camera (owner of this FSM) to the new cameraPosY

I hope this will help you to get your work to advance.