playMaker

Author Topic: Jittering Camera [SOLVED]  (Read 4502 times)

jayhfd

  • Junior Playmaker
  • **
  • Posts: 71
Jittering Camera [SOLVED]
« on: November 17, 2011, 07:48:57 PM »
Hi,
First post here, loving Playmaker so far!

After much head scratching on how to get an object to orbit a planet, I've finally succeeded and managed to keep the orbiting object facing the planet. I have a camera attached to the orbiting object which looks at its own velocity. It all works really well with one exception, there seems to be some occasional random jitter.

I'm not sure if the camera is fighting something else, but the jitter ranges from hardly noticeable to occasional big, quick swings. It seems completely random, *maybe* it increases more the longer its been running for, and *maybe* I've noticed it happen more when it makes a close pass over the collision mesh, but its still unpredictable.

As a breakdown, I've set up my scene like so:

Orbiting object:
Look at planet 0,0,0
Use a sample curve for gravity at different distances from 0,0,0
Add force (gravity) along z axis

Main Camera, child of above object:
Get orbiting object velocity and position, add them together, smooth look at that position.
Empty game object (also child of orbiter) placed -20 on the z axis to use as the up vector position for smooth look.

I'm not 100% sure but I think the jitter occurs only/mainly on the x axis (relative to the camera) ie, it jerks left and right. It's hard to tell if the movement is a rotation or not but I'm pretty sure it is jerking/rotating around the y axis.

I've checked the debug ray for the look at 0,0,0 fsm, and the ray always seems to stay on 0.
Have also checked the debug ray for looking at velocity, but its quite difficult to check on a moving object!

There are no other scripts running, and the other fsms on the orbiter and camera shouldn't have any effect.

Any thoughts what might be causing it? Or if I've done this correctly to begin with?

Thanks,
Jay

*edit
For more clues...
At the game start, there is a big glitchy rotation that happens around the z axis, which then just always irons itself out after its rotated back and forth once or twice. I'm guessing though that this is due to the fact that there is no velocity right at the start, so the camera is somehow trying to look at the orbiter, which it is right on top of (the camera is right on top of the orbiter, ie first person).
« Last Edit: November 30, 2011, 10:31:09 PM by alexchouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Jittering Camera
« Reply #1 on: November 17, 2011, 07:57:22 PM »
Hi,

It looks like you are having gimbal lock symptoms.

Also what exactlyare you trying to achieve? Cause orbiting around an objet can be made very simple by simply organising the hierarchy. Have your sattelite parented to an empty gameobject tht is centered to you planet and done, simply rotate this gameobject and your sattelire will look good. Or do you actually really want forces and gravity to interact in a real way ?

Bye

Jean



jayhfd

  • Junior Playmaker
  • **
  • Posts: 71
Re: Jittering Camera
« Reply #2 on: November 17, 2011, 08:02:16 PM »
Thanks Jean I'll look up some gimbal stuff now and see if I can figure it out.

I certainly need it to be more than just a rotation around an object, its part of the gameplay.

Cheers!
Jay

jayhfd

  • Junior Playmaker
  • **
  • Posts: 71
Re: Jittering Camera
« Reply #3 on: November 17, 2011, 08:52:49 PM »
Does PlayMaker use quaternions (seemingly the solution)? I have a feeling all physics related stuff just uses it? Also can't see much in the way of FSM actions that have quaternion in their name, can I use them specifically somehow?

I've been playing around more with my scene and I tried to also set an Up Vector on my orbiter object. This also uses the Up Vector game object set at -20 z-axis. Using this greatly increases the amount of left to right jerking motions (its now constant). So I'm thinking that maybe somehow using this on the main camera is causing the problem?

Quite hard to tell whats going on, especially with my severe lack of spacial knowledge/vectors/code etc!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Jittering Camera
« Reply #4 on: November 18, 2011, 10:20:17 AM »
Hi,

 Are you controlling the camera movement with playmaker or a script?

you need to split the problem. Is the orbit system works and is the camera system works. Or do they both works and it's when you combine them that it starts to jitter?

 Bye,

 Jean

jayhfd

  • Junior Playmaker
  • **
  • Posts: 71
Re: Jittering Camera
« Reply #5 on: November 21, 2011, 05:35:20 PM »
Well I somewhat solved it. Just redid how the orbit system worked so that instead of having the camera pointed at the planet and adding a gravity force along z, I instead took the orbiter position and inverted it, and added force in that direction. Seems to have fixed it, even though I was unsure exactly what was causing it!

Thanks for the input and help. And yeah, its all playmaker, no scripts. Hope to show it off to everyone here soon.

Regards,
Jay

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Jittering Camera
« Reply #6 on: November 23, 2011, 10:16:06 AM »
Hi,

 it was very likely a gimbal lock. I am glad you got it sorted!

 Bye,

 Jean