This.entity().setposition() Is Broken

Discussion in 'Technical Discussion' started by DanFarfan, Oct 17, 2018.

  1. DanFarfan

    DanFarfan Avid Boxer

    Joined:
    Sep 22, 2018
    Messages:
    101
    Likes Received:
    42
    For some time now I've been experimenting with the Pool example game to get to know the BB3 environment. I've seen some strange behavior that I think is related to setPosition() that I haven't been able to completely explain to tie break between "my mistake" and "BB3 problem."

    Today I had a breakthrough of sorts. This is easily reproducible and clearly not what Nik or any of his team intended.

    Open a new project and select "Flap" (the one with the character ball rolling up the ramp).

    Place the Position Animation on the platform (i.e. ramp) (The Rotation Animation node demonstrates the problem also) and set the End Position to 3, 0, 0. (Any End Position demonstrates the problem, but imo, 3,0,0 shows it particularly clearly.
    Hook up the Start node to the Position Animation node ... and preview the game.

    Je vous ai maintenant! (Me to the bug: "I have you now!")

    Set position moves the visual of the platform object, but not the collision shape? mesh? thingy.

    I know what your thinking... oh.. simple. Just rebuild the shape. Nope. Doesn't help.
    I added thus to the Position Animation code ...

    As a side question, if we added:
    } else _enabled = false;

    on the "counter < 1" conditional, couldn't we save some cpu cycles?

    So, all that's left is the closing questions... Am I nuts? Is there a workaround?

    Thanks for any help.

    @DanFarfan
     
  2. Nathan Meier

    Nathan Meier Boxer

    Joined:
    Dec 24, 2018
    Messages:
    12
    Likes Received:
    0
    I know that if an object has physics and its type is set to dynamic, you'll get weird results using setPosition(). It'll only move the visual representation of the object, but the collider will not move with it for some reason. Is your physics type on your object set to dynamic? If you want to use set position properly, you need to set the physics type for the object to kinematic.
     
  3. Nathan Meier

    Nathan Meier Boxer

    Joined:
    Dec 24, 2018
    Messages:
    12
    Likes Received:
    0
    correction, you can use setPosition with dynamic physics. But you gotta be using rebuildShape() alot. I just put it in the update method and the collider seems to stay on top the object.
     

Share This Page