Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Unity 3D + After Effects .JSON file with position over time

  • Unity 3D + After Effects .JSON file with position over time

    Posted by Neto Dal bon on May 11, 2023 at 3:12 pm

    Hey everyone!

    I’m creating vídeos for mobile games and I record all the scenes on Unity 3D. I use a PS5 controller to play and Unity records the X and Y position of my analogic stick on a .json file (30 FPS – The information is record 30 times every second / Position interval of -1 and 1, being 0 the center of the stick and -1 and 1 the left, right, top and bottom max position of the stick) and it looks like this:

    [{“x”:0.10917455,”y”:0.0},{“x”:0.1479061,”y”:0.0},{“x”:0.196320519,”y”:0.0}…with hundreds of lines…

    All the game HUD is recreated in after effects because I have to work with different aspect ratios and better animations. I want to parent this position over time value on the .json file to an animated analogic stick I created on after effects.

    I’ve been working with after effects over the past 8 years, but never used a .json file. The developer that I’m working with can format the .json anyway I want to, I just wanted to know if there’s a right way to do it, so after effects will be able to read the value and parent it to the position of my analogic stick on after effects.

    Thanks!

    Neto Dal bon replied 3 weeks, 2 days ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    May 11, 2023 at 4:17 pm

    I’d start with something like this maybe:

    data = footage("test json.json").sourceData;
    dataRate = 30;
    idx = clamp(Math.round(time*dataRate),0,data.length-1);
    x = data[idx].x;
    y = data[idx].y;
    [x,y]
  • Neto Dal bon

    May 12, 2023 at 2:46 pm

    Thank you very much Dan. It worked like a charm!

    I have one more question, the joystick is very sensitive and sometimes it flickers a lot during a diagonal movement or a slow movement. Is there a way to make the movement a little bit smoother? Maybe round the numbers, based on the next and previous frames(values), so it moves a little bit on the same path, something like this…

    Thanks in advance!

  • Brie Clayton

    May 12, 2023 at 3:55 pm

    Thank you for your helpful solve, Dan!

  • Dan Ebberts

    May 12, 2023 at 9:12 pm

    If you apply the expression to a slider, for example, I guess you try smoothing that result in another slider, with something like this:

    s = effect("Data Slider")("Slider");
    s.smooth(.2,5)
  • Neto Dal bon

    May 15, 2023 at 1:49 pm

    Thanks Dan! Problem solved!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy