playMaker

Author Topic: Playmaker rotation help please... [SOLVED]  (Read 12353 times)

Adam Z

  • Full Member
  • ***
  • Posts: 207
Playmaker rotation help please... [SOLVED]
« on: January 09, 2013, 09:35:37 AM »
Im new to playmaker and I'd like to to rotate a GameObject around the Y axis, having the 'A' and 'D' keys determine the rotation (left/right). I have no problem setting up the keys, but the iTween rotations confuse me. What I would like to do is that when you press and hold the 'A' key, the object begins to slowly rotate left until it gets to it max rotation speed, and when you let the 'A' key go, it will slow down with a smooth transition, instead of just stop abruptly.

I tried the 'iTween Rotate By' action. That sort of works. I have it store the rotation in a Vector3, with an Ease In Sine. But when it completes the full 360 degree revolution it stops, pauses and starts again instead of continuing to rotate until I let go of the 'A' key. It seems to be the Ease Type. When I choose Linear it keeps looping. Is there another setup to allow for an Ease In when pressed, and Ease Out when de-pressed?

Derkoi suggested using' iTween Rotate Add' instead. Do I need to include something for the Events, or leave that blank since it won't rotate at all?

Thanks!
« Last Edit: March 28, 2013, 03:52:10 PM by adamzeliasz »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Playmaker rotation help please...
« Reply #1 on: January 09, 2013, 03:14:31 PM »
Hi,

[UPDATE PACKAGE UPDATED]

 don't use iTween for this type of commands, that's not really possible, itWeen works with hardcoded end values as target, here the target is always changing.

simply react to the A and D key and use the "rotate" action. You can tweak the input preferences to have some smoothing in the axis itself. If you want to do the smoothing, you can insert a small lerping action between the raw input and the rotation delta value. I created a custom action for lerping floats.

Try the example attached and see how I created it. Remember that it is using a custom action I wrote for the smoothing, but you don't have to use this.

bye,

 Jean
« Last Edit: March 28, 2013, 01:01:25 AM by jeanfabre »

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: Playmaker rotation help please...
« Reply #2 on: January 09, 2013, 03:32:36 PM »
Hi,

 don't use iTween for this type of commands, that's not really possible, itWeen works with hardcoded end values as target, here the target is always changing.

simply react to the A and D key and use the "rotate" action. You can tweak the input preferences to have some smoothing in the axis itself. If you want to do the smoothing, you can insert a small lerping action between the raw input and the rotation delta value. I created a custom action for lerping floats.

Try the example attached and see how I created it. Remember that it is using a custom action I wrote for the smoothing, but you don't have to use this.

bye,

 Jean


You da man!

Thanks so much for all your help. I just got my feet wet with PlayMaker, so I have a lot to grasp and understand with the "programming" side, and all of their Actions!  I owe you one... :)

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: Playmaker rotation help please...
« Reply #3 on: January 09, 2013, 04:10:27 PM »
Hi,

 don't use iTween for this type of commands, that's not really possible, itWeen works with hardcoded end values as target, here the target is always changing.

simply react to the A and D key and use the "rotate" action. You can tweak the input preferences to have some smoothing in the axis itself. If you want to do the smoothing, you can insert a small lerping action between the raw input and the rotation delta value. I created a custom action for lerping floats.

Try the example attached and see how I created it. Remember that it is using a custom action I wrote for the smoothing, but you don't have to use this.

bye,

 Jean


Where did you assign the left and right arrow keys within your attached example?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Playmaker rotation help please...
« Reply #4 on: January 10, 2013, 03:15:27 AM »
Ah ah :)  ???

 Unity comes with a predefine set of "inputs" axis. check the Unity help for it:

http://docs.unity3d.com/Documentation/Manual/Input.html

 if you read that page, you'll see that "a" and "d" key are part of the "Horizontal" input axis, and PlayMaker has an action to get Input axis values. in this case, it's very clever, it will give you a value ranging from -1 to 1. Exactly what you expect from a joystick input for example.

so, I use "get Axis" action and by design, Unity will map the "a" and "d" key as describe in the input manager.

Is that clearer?

bye,

 Jean

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: Playmaker rotation help please...
« Reply #5 on: January 10, 2013, 09:46:18 AM »
I figured that out after I posted, but thanks! :)

derkoi

  • Full Member
  • ***
  • Posts: 187
Re: Playmaker rotation help please...
« Reply #6 on: January 10, 2013, 01:29:18 PM »
Derkoi suggested using' iTween Rotate Add' instead.

I then replied with another reply after I read what you were trying to do properly.  ::) ;D

Quote
What you need to do is create a float which is a rotate speed value.

Add the rotate speed value to the rotation of the object using rotate by (dont use itween) and make sure every frame is checked.

Now, the keys increase and decrease the rotate speed value.

That's how I'd do it.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Playmaker rotation help please...
« Reply #7 on: January 10, 2013, 02:00:39 PM »
hi,

Well. to be perfectly honest, you can use iTween for this, but it's more complex and you need to master iTween and all that. so as a rule of thumbs, when you beginm only use tweening libraries to move from defined targets, not movable targets, that adds a layer of complexity to the tweening that it difficult to grasp if you are beginning with everything.

Bye,

 Jean

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: Playmaker rotation help please...
« Reply #8 on: March 27, 2013, 09:54:15 PM »
Hi,

 don't use iTween for this type of commands, that's not really possible, itWeen works with hardcoded end values as target, here the target is always changing.

simply react to the A and D key and use the "rotate" action. You can tweak the input preferences to have some smoothing in the axis itself. If you want to do the smoothing, you can insert a small lerping action between the raw input and the rotation delta value. I created a custom action for lerping floats.

Try the example attached and see how I created it. Remember that it is using a custom action I wrote for the smoothing, but you don't have to use this.

bye,

 Jean

You helped me with this and it worked great until I upgraded to 1.5.4.  It says the 'Float Lerp' is a missing action.  Has that been removed/replaced?

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Playmaker rotation help please...
« Reply #9 on: March 28, 2013, 01:00:41 AM »
Hi,

 oups. forgot to add that custom action in the package, thanks for pointing that out.

 Download the package again please, I updated the actual post.

bye,

 Jean

Adam Z

  • Full Member
  • ***
  • Posts: 207
Re: Playmaker rotation help please...
« Reply #10 on: March 28, 2013, 03:51:40 PM »
Hi,

 oups. forgot to add that custom action in the package, thanks for pointing that out.

 Download the package again please, I updated the actual post.

I appreciate it!

bye,

 Jean

cdo1955

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Playmaker rotation help please... [SOLVED]
« Reply #11 on: December 20, 2018, 08:58:40 PM »
any chance of getting an example that works the rotate up/down axis as well as the left/ right axis. Would make a good manual gun turret control.