playMaker

Author Topic: Limit Axis Rotation between 0 and 45 [SOLVED]  (Read 2689 times)

createasaurus

  • Full Member
  • ***
  • Posts: 146
Limit Axis Rotation between 0 and 45 [SOLVED]
« on: March 06, 2014, 03:25:46 PM »
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#msg29678

Here 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.
« Last Edit: March 07, 2014, 10:06:28 AM by createasaurus »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Limit Axis Rotation between 0 and 45.
« Reply #1 on: March 06, 2014, 03:41:46 PM »
I did something similar when I was hacking up a Crane simulation at work.

Maybe its not the best way? It worked okay for me for what I was doing, and it wasn't very complicated. Just rotate it to your extents and see what the values are, then put those in the Compare's.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

createasaurus

  • Full Member
  • ***
  • Posts: 146
Re: Limit Axis Rotation between 0 and 45.
« Reply #2 on: March 06, 2014, 05:02:03 PM »
Hi Lane,
I'm following your direction but it just seems to ignore the Float Compare's altogether, or be glitchy.  I'm new to PlayMaker so I think I might be making some simple mistake. I'm posting images to show how I have it set up.
Thoughts?  Thank you!
« Last Edit: March 07, 2014, 10:12:55 AM by createasaurus »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Limit Axis Rotation between 0 and 45.
« Reply #3 on: March 06, 2014, 05:10:12 PM »
In either of the kicker states you have would need to force the radius to something less than that which triggers it to stop the player. Otherwise it will wait a second (the wait for my crane was to disable movement so you realize its the end of the line) and then return, only to be immediately triggered and go to the kicker state again.

It looks like you're using this for a camera (Maybe I missed that in the first thread) so I just realized that there are some mouse look scripts that have restrictions like that and are quite seamless. Might be worth looking into them and seeing how they handled the stops. I think this particular system might be a little clunky for a camera system, my crane was very slow and precise, so there were few artefacts and issues with doing something like this.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

createasaurus

  • Full Member
  • ***
  • Posts: 146
Re: Limit Axis Rotation between 0 and 45.
« Reply #4 on: March 06, 2014, 05:16:14 PM »
I've been playing with MouseLook, but to no avail.  I'm mostly just throwing random darts now to see if anything magically works.  If anyone has any ideas on a direction to take with this, I'd be very appreciative.
« Last Edit: March 07, 2014, 10:07:00 AM by createasaurus »

createasaurus

  • Full Member
  • ***
  • Posts: 146
Re: Limit Axis Rotation between 0 and 45.
« Reply #5 on: March 07, 2014, 10:06:07 AM »
Sometimes in life you need to make a compromise.  So I have developed a different solution which accomplishes what I need, more or less.

Instead of having my camera dynamically rotate up and down on X, I now have 3 X positions (low, mid, and high.)  Tilting the stick up and down switches among these 3 positions.  I have additional states to check that the stick centers between jumps, so you don't go Up, Up or Down, Down unintentionally.

As a beginner with PlayMaker, I realize I need to stick to simple solutions that I can understand easily.  My problem is I never know if what I am trying to accomplish is going to be simple, or crazy complex.  So, I'll be open to adjusting my project to towards the easier PlayMaker solutions, for now.   And as I gain more experience, I'll take on more and more.