Character Movement Limit - Buildbox 3

Discussion in 'How Can I...?' started by itzonator, Jun 13, 2019.

  1. itzonator

    itzonator Serious Boxer

    Joined:
    Dec 18, 2017
    Messages:
    594
    Likes Received:
    228
    Hey boxers,

    I've been trying to figure out character movement limit on X-axis only. Since that's a 3D game and the character moves left-right on X-axis, but there's a wall and the character is passing through that wall.

    I'd like to limit the character's position when move on the X-axis so that character does not pass through the wall, do you know how to do this in BB3 (official release)?

    And yes, I've been trying to do this with Position Limiter node, but it does not work! Is there a way to restrict movement of character for X-axis? So it can move, but just a little bit within the game path.

    Thanks,
    Itzo
     
  2. weboha

    weboha Avid Boxer

    Joined:
    Aug 8, 2018
    Messages:
    239
    Likes Received:
    178
    i am using Position Limiter node its works on my game. is your character kinematic?
     
  3. itzonator

    itzonator Serious Boxer

    Joined:
    Dec 18, 2017
    Messages:
    594
    Likes Received:
    228
    Yes man, it's Kinematic. If I change it to Dynamic the game falls apart. So I need a solution for Kinematic Physics properties.
     
  4. weboha

    weboha Avid Boxer

    Joined:
    Aug 8, 2018
    Messages:
    239
    Likes Received:
    178
    yes you should use kinematic. did u add limits on node?
     

    Attached Files:

  5. itzonator

    itzonator Serious Boxer

    Joined:
    Dec 18, 2017
    Messages:
    594
    Likes Received:
    228
    I have set similar parameters with Position Limiter, it should work in general, but the game in preview is distorted and the objects are not visible on screen when I have this Position Limiter node on Actor -> Start Node -> Position Limiter. The main character is distorted and colors are flashing all over the place. Maybe this is due to the kinematic physics option. Actor cannot be dynamic due to nature of gameplay.
     
  6. Killjoy1432

    Killjoy1432 Boxer

    Joined:
    Feb 2, 2019
    Messages:
    33
    Likes Received:
    6
    I've done something similar in my game i couldn't figure out how to correctly use the position limiter node so to fix it i used the swipe 3 lane asset in the smart assets and got the same effect you can set a limit with the nodes attached to it worked great for me but only if your using swipe and not touch to move anyway hope it helps
     
  7. itzonator

    itzonator Serious Boxer

    Joined:
    Dec 18, 2017
    Messages:
    594
    Likes Received:
    228
    Good suggestion, my game is touch control.
    I have figured it out with position limiter, but partially, since my game direction is in the -Z axis I was having low number there, so I was limiting the character’s movement on the game direction so it could not move forward lol that caused the distortion and flashes of assets.

    But that is exactly what I want to do to limit position in the game direction, like in BB2, there was a game frame that can be adjusted (like we have start and end scene here in BB3), but this is missing in BB3, I guess. So instead of a value to be put to limit character movement, I think we should have like BB2 , game frame within which the character to move in that area! And this game frame can be stretched and modified with the BB3 tools (rotation, scale, move). @NikRudenko
     
  8. rizwanashraf

    rizwanashraf Avid Boxer

    Joined:
    Dec 3, 2015
    Messages:
    344
    Likes Received:
    215
    You can do something like If your Character is at X = 5 then X is equal to 5 or same for the -5 that way you can clamp the values easily. i believe! I could be completely wrong though :)
     
  9. tonymartz2

    tonymartz2 Avid Boxer

    Joined:
    Jun 9, 2016
    Messages:
    198
    Likes Received:
    46
    same issue here my game is moving an an x axis at 5, I set up an invisible box using position limiters so that the actor stays within set perimeters. the Z limiter works fine for left and right, however the front and back limiter do not scroll with the gameplay that is moving on the X axis at 5... is this a glitch or am I doing something wrong?
    what's happing is that as game starts to move forward on the X axis the invisible barrier pushes the actor down to the bottom of the screen.
    can't figure out how to make limiter move with game it self..
    my actor is kinematic
     
  10. itzonator

    itzonator Serious Boxer

    Joined:
    Dec 18, 2017
    Messages:
    594
    Likes Received:
    228
    I was able to figure it out when playing with Position Limiter parameters. Try everything from 1 to 999 from -1 to -999 on each axis and see how it would perform. It's really gameplay-dependent. I figured it out when added the number 9999 for z-axis in Position Limiter and it worked, you may need to have different adjustments :D

     
  11. tonymartz2

    tonymartz2 Avid Boxer

    Joined:
    Jun 9, 2016
    Messages:
    198
    Likes Received:
    46
    tried it all with no luck, it seems like I can get the X axis limiter to work.
    I created the desire "virtual fence" but it does not move with the game play on the X axis... that fence/limiter goes off screen as the game play moves forward.
    i can't get it to move with the actor to maintain those set parameters. the Z axis works find and the Y is not required for my game...
     
  12. Selvamax

    Selvamax Boxer

    Joined:
    Dec 30, 2019
    Messages:
    10
    Likes Received:
    1
    Position Limiter works on Kinematic too. Use a little script like limiting the character edges from camera angle.
    var animObj = this.scene().camera(); // init method
    remove _max and _min initialisation in start method and use update method like this
    _max = animObj.position();
    _max.x = animObj.position().x + 5; //limiting positive x axis based on camera
    _max.y = animObj.position().y + 17; //limiting positive y axis based on camera
    _min = animObj.position();
    _min.x = animObj.position().x - 5; //same for negative
    _min.y = animObj.position().y-2; //same for negative
    // leave other position script as it is...
    while altering and use this little script u will get dynamic limitation on endless game. I m embedding my whole position limiter script for you reference

    *** Starts ***


    var _max;

    var _min;

    var _enabled = false;

    var animObj;

    function init()

    {

    animObj = this.scene().camera();

    }



    function start(){



    }



    function update(dt){

    if(!_enabled)

    {

    return;

    }

    _max = animObj.position();

    _max.x = animObj.position().x + 5;

    _max.y = animObj.position().y + 17;

    _min = animObj.position();

    _min.x = animObj.position().x - 5;

    _min.y = animObj.position().y-2;



    let pos = this.entity().position();

    if(_max.x != null && pos.x > _max.x){

    pos.x = _max.x;

    }

    if(_max.y != null && pos.y > _max.y){

    pos.y = _max.y;

    }

    if(_max.z != null && pos.z > _max.z){

    pos.z = _max.z;

    }



    if(_min.x != null && pos.x < _min.x){

    pos.x = _min.x;

    }

    if(_min.y != null && pos.y < _min.y){

    pos.y = _min.y;

    }

    if(_min.z != null && pos.z < _min.z){

    pos.z = _min.z;

    }



    this.entity().setPosition(pos.x, pos.y, pos.z);

    }



    function signal(name, value){

    _enabled = value;

    }

    *** Ends ***
     

Share This Page