playMaker

Author Topic: [SOLVED] How do you zoom an orthographic camera in and out?  (Read 10257 times)

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
Is it possible to use Playmaker to zoom an orthographic camera in and out?  I don't see any native actions that would accomplish this, since to zoom in/out with an orthographic camera you have to actually change the size of the camera.
« Last Edit: May 12, 2012, 05:49:52 PM by Disastercake »
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com

Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
Re: How do you zoom an orthographic camera in and out?
« Reply #1 on: May 12, 2012, 05:28:52 PM »
In case anyone is interested in my work-around custom action, here it is.  There's a bit of other work outside of this action to get it working properly, but you can get the gist of what needs to be done here:

http://www.youtube.com/watch?feature=player_embedded&v=MANk3Bj4Nkk#!

Skip to around 10:00 minutes in to see the zooming part.

I still think there should be a native action for altering the orthographic camera size, though.

Code: [Select]
using UnityEngine;
using System.Collections;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Soul Saga")]
[Tooltip("Gets the Y Position of the mouse and stores it in a Float Variable.")]
public class CameraScrollWheelZoom : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat floatScroll;
public bool everyFrame;

public override void Reset()
{
everyFrame = false;
}

public override void OnEnter()
{
DoScroll();

if (!everyFrame)
Finish();
}

public override void OnUpdate()
{
DoScroll();
}

void DoScroll()
{
if (floatScroll.Value > 0)
{
if (Camera.main.orthographicSize <= .6)
{
Camera.main.orthographicSize = .5f;
return;
}
else
{
Camera.main.orthographicSize -= .1f;
}
}

if (floatScroll.Value < 0)
{
if (Camera.main.orthographicSize >= 9.9)
{
Camera.main.orthographicSize = 10f;
return;
}
else
{
Camera.main.orthographicSize += .1f;
}
}
}
}
}
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3985
  • Official Playmaker Support
    • LinkedIn
Re: How do you zoom an orthographic camera in and out?
« Reply #2 on: May 12, 2012, 05:45:51 PM »
You can use Set Property to set the camera's Orthographic Size. Just drag the Camera component into the Target Object field and find the orthographicSize property.

Or there's a custom action here:
http://hutonggames.com/playmakerforum/index.php?topic=1321.0

Also you can get Scroll Wheel input with Get Axis "Mouse ScrollWheel":
https://hutonggames.fogbugz.com/default.asp?W192


Disastercake

  • Full Member
  • ***
  • Posts: 101
  • www.disastercake.com
    • Disastercake
Re: How do you zoom an orthographic camera in and out?
« Reply #3 on: May 12, 2012, 05:49:39 PM »
Thanks! =D  Good to know.
Soul Saga - Anime themed adventure RPG by Disastercake

http://www.disastercake.com