# playMaker

### Author Topic: DO Tween Rigidbody 2D Rotate  (Read 254 times)

#### 3D Lunatic

• Playmaker Newbie
• Posts: 17
##### DO Tween Rigidbody 2D Rotate
« on: October 13, 2019, 01:58:49 PM »
Another pinball question, if you don't mind:

I'm using DO Tween Rigidbody 2D Rotate (Playmaker action) to rotate my flippers which have a rigid body 2D to hit the ball. I set my angle to a desirable value (30 degrees) but when the flippers rotate, they don't hit this value. They only go up to 20 degrees, and sometimes they don't return to 0 when I use the same tween to rotate them back.

I think the problem may be that I have to rotate them very fast. My duration is 0.05 seconds. I think this may be breaking the tween.

Is there another action I could use on a 2D rigidbody to rotate it like a pinball flipper? I just want to to rotate 30 degrees when the key is pressed, and then rotate back to 0 when released. Do I set up some kind of loop, incrementing the rotation by a degree for 30 updates (or physics updates), and then back? How can I set up the loop? I'm new to Playmaker. Any help is greatly appreciated.

#### ch1ky3n

• Full Member
• Posts: 117
##### Re: DO Tween Rigidbody 2D Rotate
« Reply #1 on: October 13, 2019, 09:07:27 PM »
Hi there,

Just for a quick check

1. Have u set the pivot of your flipper to the edge? Cuz rotation is based on the pivot

2. If you do, make sure to set the rigidbody2d to kinematic so it wont affected by gravity

3. There is a command called Ease Float, basically it is gradually increased your float variable within certain time

4. The rotation of the flipper will be on Z coordinate

So we go something like this:

State 1: Get key down

State 2 : Rotate flipper.rotation.z = variable myRotation
Ease float myRotation variable from (eg:0 to 30) in 0.05 sec, when    finished back to state 1

See how it goes

#### 3D Lunatic

• Playmaker Newbie
• Posts: 17
##### Re: DO Tween Rigidbody 2D Rotate
« Reply #2 on: October 13, 2019, 11:48:10 PM »

1. Have u set the pivot of your flipper to the edge? Cuz rotation is based on the pivot
Yes, the flipper is the child of the flipper_hinge, and moved to align the flipper_hinge pivot to the correct place. The flipper_hinge has a rigidbody and Playmaker FSM on it, the flipper itself only has a collider and physics material.

2. If you do, make sure to set the rigidbody2d to kinematic so it wont affected by gravity
Yes, I have the rigidbody 2D set to kinematic.

3. There is a command called Ease Float, basically it is gradually increased your float variable within certain time
Okay, this may be what I'm looking for. I'll see if I can find Ease Float in the Playmaker actions and use it instead of the DO Tween.

4. The rotation of the flipper will be on Z coordinate
Yes, I'm rotating on the correct axis.

So we go something like this:

State 1: Get key down

State 2 : Rotate flipper.rotation.z = variable myRotation
Ease float myRotation variable from (eg:0 to 30) in 0.05 sec, when    finished back to state 1

In my case I actually have 4 states:
(1) Wait for key down
(2) Rotate flipper up
(3) Wait for key up (release)
(4) Rotate flipper back down

And back to state 1. All that seems to work fine but I'll try the Ease Float action and see if it helps. Thanks for your answer.