Drag controlled rotation


(Nick ) #1

All:

Brain Lock here…
I have built slider controls vertical and horizontal without issue.
But I am trying to make a control that allows the user to drag on an object and it will then rotate around the set axis.

I am somewhat of the way there.
I can drag on the element
it will control the timeline of choice "turn"
However I want to be able to drag it in both directions let it set at any angle when I let go.

What have I forgotten?
Thanks!
Nick

turn.zip (12.2 KB)


(Nick ) #2

Ugh I think I have it.
Not very elegant though.
I put a pause timeline action on every frame…
prototype.zip (35.9 KB)


(Jonathan Deutsch) #3

Did you try unchecking “Continue after drag?”

I think to do this right you won’t want to use the built-in Control Timeline action. Instead I’d do something like:

  1. Add a Run JavaScript for the On Drag
  2. With the event['hypeGestureXPosition'] and event['hypeGestureYPosition'] use trigonometry to calculate the angle of rotation that the cursor is at
  3. Convert this to a percentage of the timeline that is complete
  4. Convert the percentage to a time on the timeline via hypeDocument.durationForTimelineNamed()
  5. Drive the timeline with the time via hypeDocument.goToTimeInTimelineNamed() API function

(Nick ) #4

Thanks @jonathan I will try it.
I won’t need super exact control since this is for a drag illustration model.
And turning off the continue after drag did work…time for more coffee.