playMaker

Author Topic: Lack of FixedUpdate options - where to model this code?  (Read 1632 times)

cdutoit

  • Playmaker Newbie
  • *
  • Posts: 28
Lack of FixedUpdate options - where to model this code?
« on: February 10, 2015, 08:56:45 PM »
I have this code:

Code: [Select]
void FixedUpdate () {

if (jump != Vector2.zero) {
// Jump a bit, set new Position
Vector2 pos = transform.position;
Vector2 newPos = Vector2.MoveTowards(pos, pos+jump, speed);
transform.position = newPos;

// Decrease jump vector a bit
Vector2 step = newPos - pos;
jump -= step;
} else
{

if (Input.GetKey (KeyCode.UpArrow))
jump = Vector2.up * jumpSize;
else if (Input.GetKey (KeyCode.RightArrow))
jump = Vector2.right * jumpSize;
else if (Input.GetKey (KeyCode.DownArrow))
jump = -Vector2.up * jumpSize;    // -up means down
else if (Input.GetKey (KeyCode.LeftArrow))
jump = -Vector2.right * jumpSize; // -right means left
}

   }

Implementing this in Playmaker is proving to be a bigger challenge than I thought.

First, when I change (in code) from FixedUpdate to Update, it causes occasional erratic behavior, so it really needs to be FixedUpdate.

However, to implement it in PlayMaker actions, none of these Actions support a "fixedupdate" mode:

  • GetPosition
    Vector3 to Vector2
    Vector2 Add
    Vector2 Move Towards
    Set2dPosition
    Vector2 Operator

Those are all the actions I need to implement this extract:

Code: [Select]
if (jump != Vector2.zero) {
// Jump a bit, set new Position
Vector2 pos = transform.position;
Vector2 newPos = Vector2.MoveTowards(pos, pos+jump, speed);
transform.position = newPos;

// Decrease jump vector a bit
Vector2 step = newPos - pos;
jump -= step;

So am I missing something - How can I implement the above with FixedUpdate actions?

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Lack of FixedUpdate options - where to model this code?
« Reply #1 on: February 17, 2015, 01:27:20 AM »
Hi,

 indeed, this is a problem with the official set of actions, You'll need to get custom actions for this, most of them are accessible and easily searcheable with a one click install button via the Ecosystem

typically, I named all the actions with "advanced" when they allow you to define when to perform the action , update, late or fixed.

so, try to find the "advanced" version of the actions you used on your fsm,

If you keep struggle, let me know. the input management should be something you can take out of the fixed update, so you are left with movetowards ( which had its advanced version on the ecosystem), and "float Multiply Advanced" and/or "float operator Advanced".

If you need other advanced actions, let me know, I'll provide.

 Bye,

 Jean