Timer Confusion?
Hi all, n00b to GS here, and I've found I've just not got my head round the timing of events etc.
I've got an Actor, that when pressed, I simply want to rotate counter-clockwise 45 degrees quickly, then a little slower return to 0 degrees rotated. Essentially, the Actor 'brakes/decelerates' when you tap it.
I've tried a couple of Timers for this, but the behaviour in Preview is erratic.
Rule etc:
---------------------------------------------
- Rule DECELERATE
When All conditions are valid:
Actor receives event touch is pressed
- Timer
After 0 seconds Ticked Run to Completion
- Interpolate
self.Rotation to: 45
Duration 0.1
- Timer
After 0.1 seconds Ticked Run to Completion
- Interpolate
self.Rotation to: 0
Duration 0.5
---------------------------------------------
So sometimes the Actor performs as desired, sometimes it just rotates a few degrees before returning to 0, sometimes stays rotated, sometimes flips out and spins right round. Whether this is based on the event being 'pressed' I do not know.
What am I just not getting, guys?
Many many thanks in advance.
I've got an Actor, that when pressed, I simply want to rotate counter-clockwise 45 degrees quickly, then a little slower return to 0 degrees rotated. Essentially, the Actor 'brakes/decelerates' when you tap it.
I've tried a couple of Timers for this, but the behaviour in Preview is erratic.
Rule etc:
---------------------------------------------
- Rule DECELERATE
When All conditions are valid:
Actor receives event touch is pressed
- Timer
After 0 seconds Ticked Run to Completion
- Interpolate
self.Rotation to: 45
Duration 0.1
- Timer
After 0.1 seconds Ticked Run to Completion
- Interpolate
self.Rotation to: 0
Duration 0.5
---------------------------------------------
So sometimes the Actor performs as desired, sometimes it just rotates a few degrees before returning to 0, sometimes stays rotated, sometimes flips out and spins right round. Whether this is based on the event being 'pressed' I do not know.
What am I just not getting, guys?
Many many thanks in advance.
Best Answers
-
JustMe74 Posts: 542
Do you want to have to continue to hold your finger on the actor? If not, change the rule to when touch is released, rather than pressed. -
MotherHoose Posts: 2,456
problem is probably when touch is continuously pressed:
… Timer1 fires continuously
IMO timers are not needed for these rotations (Interpolate has a timed duration)
objectives:
when: touch is pressed; when self.Rotation = 0
what: Interpolate: self.Rotation To: 45
when: touch is released; when self.Rotation ≥ 45
what: Interpolate: self.Rotation To: 0
that can be written as one rule with touch released in its Otherwise: section
or 2 separate rules
setting Interpolate's Function: Ease in/out … makes this smoothMH
Answers
'Rising' really nicely when it brakes now.