Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Disastercake on May 12, 2012, 04:23:27 PM

Title: [SOLVED] How do you zoom an orthographic camera in and out?
Post by: Disastercake on May 12, 2012, 04:23:27 PM
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.
Title: Re: How do you zoom an orthographic camera in and out?
Post by: Disastercake 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;
}
}
}
}
}
Title: Re: How do you zoom an orthographic camera in and out?
Post by: Alex Chouls 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

Title: Re: How do you zoom an orthographic camera in and out?
Post by: Disastercake on May 12, 2012, 05:49:39 PM
Thanks! =D  Good to know.