Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started 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.
-
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.
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;
}
}
}
}
}
-
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
-
Thanks! =D Good to know.