I am setting up a camera system similar to the Captain Toad levels in Super Mario World. Basically the camera always points to the center of the game level, and you can circle the camera around on Y and X with the analog stick. Here is a little video example of what I'm trying to emulate (Captain Toad.)
I have things set up fine so far! I use the analog stick to rotate Y and X around the scene, pointing at center, feeling natural and good. The trouble I'm having is setting some limits on X. I'd like to keep it so you can't go too high and loop over, and you can't dip below the horizon line. The ideal the X range should be between 0 and 45. Hopefully this range simplifies things, considering there are not any negative rotation values.
This is what I've tried and failed at:
1.) Using Float Compare so when I'm greater the 45, goto a new state to Set Float Value to 45, then return.
2.) Using Float Clamp then Set Rotation. Result: It is an interesting effect, the rotation locks directly to the control stick, so when you let go, it jumps back to 0. Or when you push all the way up, it jumps to 45. Not what I'm looking for.
3.) Reading many examples from the forum. The closest I've gotten is this:
http://hutonggames.com/playmakerforum/index.php?topic=6123.msg29678#msg29678Here is the quote from Jean at the end.
Hi,
That will be a little more involving actually.
Basically you need the following:
-- a center position acting as the reference of your constraint
-- the radius
with this, everyframe you check of the position of your gameobject, and create a vector 3 of the position minus the center position, this will give you two indications,
-- the magnitude and the direction.
if the magnitude of greated than the radius, normalize this vector, and multiply it by the radius, that will be the delta position from the center position of your gameobject.
If you do this sequence, then you can still control the gameobject around, it will move within this constraint.
bye,
Jean
I've read and reread this post, trying to understand. If this is indeed the correct direction for my situation also, and this could be explained in much simpler, beginner terms, I'd be incredibly grateful. Or if anyone has any insight on this problem in general, please let me know. Thank you.