Limiting Character Speed Due To Collision Checks

Discussion in 'Buildbox 3.0' started by menanche, Oct 8, 2019.

  1. menanche

    menanche Boxer

    Joined:
    Nov 1, 2018
    Messages:
    57
    Likes Received:
    21
    Fast moving objects tend to skip the physics checks where the collision would have been.

    There are three solutions for this problem:
    • Increase the size of the object, change the collider size.
    • Establish a maximum speed for the object, so that it can never move fast enough to go through the pads.
    • Increase the frequency with which Buildbox makes its physics calculations. It can be changed in, 3D world node, increasing Sub Steps. Beware of increasing this too much, it could possibly affect the game optimization.
    Setting a maximum speed for moving objects is something that must always be done. You cannot risk having an important object skyrocket during the game and leave everything in an uncontrolled state.


    Can we get a code that can control the speed of the character? Specifically for touch move node.
    @weboha @TreySmith @NikRudenko @PunkPuffin @Josh (Nology Games) @Rusted @itzonator @Sean Buildbox @particles @Hanomax
     
    Last edited: Oct 23, 2019
  2. Hanomax

    Hanomax Avid Boxer

    Joined:
    Aug 24, 2018
    Messages:
    157
    Likes Received:
    85
    I would like to know also, how to set speed limit.
    BallFlipper template is one example, where it is needed.
     
  3. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    195
    There is a solution. Ask them to add Constant Collision Detection (CCD) options.
     
  4. menanche

    menanche Boxer

    Joined:
    Nov 1, 2018
    Messages:
    57
    Likes Received:
    21
    Yes, that sounds good, but what's the likelihood of them adding it?
    Object speed control sounds like a 10 min fix.
    Now I literally can't post the game on the app store because of that, the game is unplayable.
     
  5. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    195
    Buildbox with a speed of 1000 no collisions missed......
     

    Attached Files:

    AppNasty likes this.
  6. menanche

    menanche Boxer

    Joined:
    Nov 1, 2018
    Messages:
    57
    Likes Received:
    21
    That's exactly what I'm talking about.
    Could you possibly create speed control for the character(touch move node). I see that you can code. :D
     
  7. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    195
    What do you mean by speed control?
     
  8. menanche

    menanche Boxer

    Joined:
    Nov 1, 2018
    Messages:
    57
    Likes Received:
    21
    https://drive.google.com/open?id=1SGbeF-buKT6p5GJj5vMvX1G1UlqkhqDw -> download this bbdoc

    When swiping across the screen, the character just walks through those objects, what I would like is that even though the user swipes the screen very fast, the character goes at a certain maximum speed that will not cause the collision bug.
     
  9. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    195
    Try this in your "Touch Move" node

    Play with the 0.4 until you get what you need.

    Code:
    function touchMove(point) {
        if (!enabled) return;
        let dx = sens.x * (point.x - prev.x);
        let dy = sens.y * (point.y - prev.y);
        let vel = getVelFromScreenMove(dx,dy);
        vel = vel.normalize().scale(0.4);
        delta = delta.add(vel);
        prev = point;
    }
     
    menanche likes this.
  10. menanche

    menanche Boxer

    Joined:
    Nov 1, 2018
    Messages:
    57
    Likes Received:
    21
    Yes, that's it. It does not happen that a character passes through objects.
    But ..
    now there is a lot of offset in character control by swiping your finger. It would need to rework the entire node for it to function fluidly. Of course, this is something the buildbox team needs to do, I can't ask you to do that.
    I wrote buildbox support about this, I was told it would be taken into consideration ...
     
  11. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    195
    Can you adjust your sensitivity now?
     
  12. menanche

    menanche Boxer

    Joined:
    Nov 1, 2018
    Messages:
    57
    Likes Received:
    21
    For my game, the sensitivity must be 1.5, the reason being that the finger should always be below the character, when swiping across the screen.
    @PunkPuffin What exactly did you mean?
     
  13. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    195
    The problem you might have is setting a speed that works means your character is likely to move quite slow which also counteracts the sensitivity. The more sensitive the quicker it would move for smaller movements but then you are limiting the speed so essentially all you are doing is accelerating quicker to the max speed.

    I’ll take a look when I can.
     
  14. Okafor Somtoo

    Okafor Somtoo Boxer

    Joined:
    Aug 23, 2018
    Messages:
    2
    Likes Received:
    0
    I don't know if it's too late. But to set the maximum velocity of an object - add a position limiter node (you can change its name to 'Velocity Limiter', this node will enable you to set both the maximum and minimum velocity of an object), then replace its script with below
    //starts here
    var _max;
    var _min;
    var _enabled = false;
    function init(){
    _max = this.attribute('Max');
    _min = this.attribute('Min');
    ent = this.entity().physics()
    }

    function start(){

    }

    function update(dt){
    if(!_enabled){
    return;
    }

    let vel = ent.linearVelocity();
    if(_max.x != null && vel.x > _max.x){
    vel.x = _max.x;
    }
    if(_max.y != null && vel.y > _max.y){
    vel.y = _max.y;
    }
    if(_max.z != null && vel.z > _max.z){
    vel.z = _max.z;
    }

    if(_min.x != null && vel.x < _min.x){
    vel.x = _min.x;
    }
    if(_min.y != null && vel.y < _min.y){
    vel.y = _min.y;
    }
    if(_min.z != null && vel.z < _min.z){
    vel.z = _min.z;
    }

    ent.setLinearVelocity(vel.x, vel.y, vel.z);
    }

    function signal(name, value){
    _enabled = value;
    }
    // ends here
     

Share This Page