playMaker

Author Topic: Jittering being caused by OnUpdate?  (Read 2616 times)

VectorF22

  • Junior Playmaker
  • **
  • Posts: 50
Jittering being caused by OnUpdate?
« on: June 22, 2015, 01:07:34 PM »
I'm creating a ball maze game and I'm using the "Set Gravity From Acceleration" action to move the ball across the stage. The problem is there's a certain degree of jittering on the ball as it moves around the stage.

The camera isn't causing the problem as I've intentionally kept the camera stationary while I'm testing it.

Interpolation is set to "Interpolate" as using either other option causes far worse problems.

Looking around online, it looks like a potential problem might be down to the fact that the SetGravity() method in the action is being called in "OnUpdate()" where it is good practice to have any physics calculations made in "FixedUpdate()" or "OnFixedUpdate()" instead. I've tried altering "OnUpdate()" to be both of these, but neither of them actually work. It's not that it doesn't solve the jittering, it's that the ball doesn't end up moving at all... :/


Any ideas how I could get it to work in FixedUpdate or what else might be causing the jittering?

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Jittering being caused by OnUpdate?
« Reply #1 on: June 23, 2015, 01:09:33 AM »
Hi,

 can you reference where you go this action, and I'll modify it so that you can shoose when to apply this.

 Bye,

 Jean

VectorF22

  • Junior Playmaker
  • **
  • Posts: 50
Re: Jittering being caused by OnUpdate?
« Reply #2 on: June 23, 2015, 04:43:47 AM »
Hey Jean,

I got the action from the EcoSystem, but I have altered it slightly so that it works with my stage setup...

Here's a copy of it....

Thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Jittering being caused by OnUpdate?
« Reply #3 on: June 23, 2015, 07:25:50 AM »
Hi,

 Just to make sure. you have actually not changed when, but how to affect gravity by making it agnostic to device orientation.

 Can you confirm this? that it works onUpdate ( you don't need to do it on FixedUpdate), and that instead it was a problem with screen device orientation?

Bye,

 Jean

VectorF22

  • Junior Playmaker
  • **
  • Posts: 50
Re: Jittering being caused by OnUpdate?
« Reply #4 on: June 23, 2015, 07:42:23 AM »
That's right, the gravity is being changed by the device orientation. There's absolutely no other forces being used on the ball.

As the action is currently setup, the ball moves across the screen as it is supposed to (with everything in OnUpdate).
The only problem is the ball jittering as it moves across the screen. Sometimes it's barely noticeable, but other times its as if it has skipped a few frames. The jittering is the type that would normally be associated with a camera moving to follow the player and them not being synced properly, but I've made the camera stationary and the jittering is still there.

I would be tempted to put it down to a complicated scene and a slow processor, but it's currently a very simple scene being used on a very powerful android device. Plus the ball is the only thing in the stage that is jittering. Anything else (such as allowing the camera to move) is smooth.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Jittering being caused by OnUpdate?
« Reply #5 on: June 23, 2015, 07:55:44 AM »
Hi,

 ok, so edit your action and do this:

Code: [Select]
public override void Awake()
        {
            Fsm.HandleFixedUpdate = true;
        }


public override void OnFixedUpdate()
{
SetGravity();
}


and tell me if that's better.

Bye,

 Jean