playMaker

Author Topic: accuracy of transform  (Read 6418 times)

elvis75k

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 97
    • nRender
accuracy of transform
« on: April 19, 2012, 05:59:40 PM »
I've been working for the last couple of days on a 2d platform.
I've read about accuracy of float number and the related issues that characterize the precision.
Now i've discovered that it will be impossible for me to move an elevator from point a=0 to point b=20 using animated variables (float animation, ease animation, curves etc). It will always reach random values near the expectations (b=19.21191 or b=20.12288). It has to be precise but it fail for ever and ever; i see a lot of things that cannot understand and i don't know how to make my choises.

1) how can i reach point a=0 to point b=20 in n seconds without having floating surprises?
2) what's the real purpose of having both speed and time in some actions?
3) What if i want to change an action to run in fixedUpdate or in lateUpdate. I don't understand how Playmaker handle their functions.. the Translate action has the option to switch to LateUpdate and the tooltip says things that i don't understand (i've read that changing this will eventually helps in case of jitter ).

iTween: looks like the option that make me possible to have accuracy of transorm but when used on object with rigidbody that interact with others physics elements results in a jitter crazy movement.
Animation: this work just fine but i want to achieve movement with variables.. is the key of the game i'm making.
Thanks in advance, elvis

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: accuracy of transform
« Reply #1 on: April 19, 2012, 06:44:50 PM »
Maybe you could have your elevator automatically round up if it gets within 1 unit of your destination then pop to that position.

elvis75k

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 97
    • nRender
Re: accuracy of transform
« Reply #2 on: April 19, 2012, 07:35:54 PM »
Maybe you could have your elevator automatically round up if it gets within 1 unit of your destination then pop to that position.
Do you mean to use set position as a finished event to force the elevator to stay at b=20?
IN THE MEANTIME
I've added a fload clamp to clamp the moveUP var from 0 to 20; added an ease float that goes from -1 to 21  and a translate that move the elevator in Y with moveUP values. The value is definitely clamped but the translation continues till the animation float -> finish event is called (exit the state). Is this normal?

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: accuracy of transform
« Reply #3 on: April 19, 2012, 11:35:26 PM »
 Do you mean to use set position as a finished event to force the elevator to stay at b=20?[/quote]

Yes.  I know its not an ideal solution, just thinking off the top of my head as a possible work around.  If Alex chimes in, i'm sure he'll know a more technical playmaker solution.

elvis75k

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 97
    • nRender
Re: accuracy of transform
« Reply #4 on: April 21, 2012, 03:58:17 AM »
I can't pass this :( It start to turn into pain/headache.

elvis75k

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 97
    • nRender
Re: accuracy of transform
« Reply #5 on: April 21, 2012, 09:08:32 AM »
In the meantime..
Ok now i have my wonderfull elevator (it is just a box) and it moves with iTween moveTo. The good news is that it works fine only when this object is not a rigidbody; the bad news is that it can't  be a rigidbody or it start to jitter like carzy (more speed = more jittering as i mentioned in the 1st post).
I can use the elvator to carry up and down the player cheating with the set parent action (that's cool).. but then i have to fight with an extreme complex fsm if i need to jump when the elevator moves.

Is there a reason for this jitter and iTween, it doesn't jitter using translate, move forward..

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: accuracy of transform
« Reply #6 on: April 21, 2012, 11:58:38 AM »
I would suggest the following approach

 1: Use a configurable joint and translate the elevator with it, using one of its axis.
 2: why would translate not working? simply watch for the value and stop when it's twenty

 I have been following this post with one eye, and I am not sure why you need such an accurate destination, 20, I mean what happen in your game if it's 19.9? Maybe the key would be to modify the behavior that doesn't work because of this inacurracy instead of trying to fight this?

to answer your question number 2:

-- speed is to reach b with a given speed: the object will not go faster then this speed in order to reach b
-- time is to reach b in a given time: the object will take exactly this amount of time to reach b.
Sometimes you want to control one, sometimes the other, it depends on what you want,

To answer your question 3:
fixed update and late update within playmaker action is something you will likely have to customize, some do use this, but not all: You can either define a boolean to control this from the action interface, or simply modify the action you want ( and duplicate it, otherwise it would get overrided in the next playmaker update).

This question 3, it could very well be the reason of your inacurracy ( stopping while the physics engine has one more round to move things, or something). If you have a scene to share, don't hesitate!


 Bye,

 Jean
« Last Edit: April 21, 2012, 12:21:27 PM by jeanfabre »

elvis75k

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 97
    • nRender
Re: accuracy of transform
« Reply #7 on: April 21, 2012, 12:34:47 PM »
Will definitely try with the joint later..
Translate do work, but if the Y direction has a float variable animated with a curve, it goes to 19.9 lol. Pheraps i can roll this moveUP var without the need of a curve? (if so i must be blind). The accuracy is part of how the level with all the platform and elevators is designed; if it doesn't match it looks like an error, that's it.

Thanks a billion for writing all that,
elvis

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: accuracy of transform
« Reply #8 on: April 21, 2012, 02:45:35 PM »
Hi,

Ok, this is odd, I tested with iTween MoveTo and it goes to 2 just fine. I tested with a rigidBody and it goes to 2 just fine. I even checked with a free rigidbody cube on top to see how it would interact, and it's perfect.

One things: make sure you check off the "Orient to Path" and "move to path", this could be your problem

I tested with animate float action, and builded a curve going to 2 ( in one seconds), and it works perfectly ( on the same rigidbody set up, and reach 2 spot on. When you edit the second curve point, is the tooltip really showing 2? use "ctrl to snap the handle if you want round numbers.

Bye,

 Jean
 

elvis75k

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 97
    • nRender
Re: accuracy of transform
« Reply #9 on: April 21, 2012, 04:23:15 PM »
Uhh.. I'm going to double check my iTween settings. The curve is linear and snapped to the grid. Now i've the  feeling that this jitter is caused by a followPlayer behaviour attached to the camera. Will stay awake all night long and report asap.
Grazie!

ps.. in the playmaker sample 'fade alpha slider' (not sure about the exact name now) i can see the slider never reach the round target value. Is it for you? Note: i always test stuff in build when i dont trust the editor.

edit: sorry the FadeGUI sample scene contains an anim curve with no round value in the end = 1.982 intead of 2.0
« Last Edit: April 21, 2012, 07:54:22 PM by elvis75k »

elvis75k

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 97
    • nRender
Re: accuracy of transform
« Reply #10 on: April 21, 2012, 09:17:25 PM »
Report: cleaning here and there a lot of complicated stuff give me less surprises.
Using iTween for the elevators is ok except if the inspector is open while run the scene..
Still can't square my animation floats for now.
simple is better and now i have something that almost works.
The sooner you'll learn that, the better.

I have start all this mess because i wanted to join the Ludum Dare contest, but i don't know if playmaker is ok since you have to share the source code with the game..  also i have so much to learn.

Here's a quick build of my work (don't laugh at me ok!)
L/R arrows to move the thing (hehe) Up arrow to jump. (the 1st elevator is the one i like)
« Last Edit: April 21, 2012, 09:58:20 PM by elvis75k »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: accuracy of transform
« Reply #11 on: April 22, 2012, 03:17:58 AM »
Hi,

 I played your game, nothing to be ashamed off actually!

Ok, I have checked the FadeGui sample, and that's what I mentioned earlier, the curve doesn't go to 2 exactly, so click and drag the point while pressing "crl" and move it to 2 exactly ( it will snap to round values), then all will be well.

 Select the point in your own curve, and if it doesnt say 2 exactly, you will of course not have 2, it will go EXACTLY where you tell to animate to. You need to be very accurate yourself when setting them values.


Bye,

 Jean