Touch Rotate Node Bugged?

Discussion in 'Buildbox 3.0' started by Catothebasterd, Jan 9, 2020.

Tags:
  1. Catothebasterd

    Catothebasterd Boxer

    Joined:
    Oct 1, 2018
    Messages:
    5
    Likes Received:
    1
    Last edited: Jan 9, 2020
    5petersonzachary likes this.
  2. Hanomax

    Hanomax Avid Boxer

    Joined:
    Aug 24, 2018
    Messages:
    156
    Likes Received:
    84
    It seems bugged indeed.
    I tested Touch Rotate node on iPhone, and it didn't work.
    Someone else tested it on Android, didn't work either.
     
  3. Catothebasterd

    Catothebasterd Boxer

    Joined:
    Oct 1, 2018
    Messages:
    5
    Likes Received:
    1
    It's still broken in 3.1.3 outside of the buildbox environment
     
  4. alp

    alp Boxer

    Joined:
    Feb 27, 2020
    Messages:
    5
    Likes Received:
    1
    it's still not working and this is the main node for my game :(
     
  5. sebb121

    sebb121 Boxer

    Joined:
    Dec 10, 2017
    Messages:
    74
    Likes Received:
    55
    Hey, I'm on 3.1.4 and I'm getting this issue. Is there an update someone from the BB team can provide? Thanks!
     
  6. Maikel Erich

    Maikel Erich Boxer

    Joined:
    Apr 2, 2020
    Messages:
    1
    Likes Received:
    0
    UP this. I have the same issue
     
  7. 5petersonzachary

    5petersonzachary Serious Boxer

    Joined:
    Jan 23, 2016
    Messages:
    541
    Likes Received:
    159
    I have this issue too!
     
  8. Codifie

    Codifie Avid Boxer

    Joined:
    Apr 17, 2018
    Messages:
    341
    Likes Received:
    162
    Try this code for your Touch Rotate. works perfect on IOS.

    Code:
    let enabled = false;
    let scrX, scrY;
    let prev;
    let phys;
    let isTouched = false;
    let forward, right;
    let delta = new Vec3(0, 0, 0);
    let sens;
    
    
    function init() {
        smooth = this.attribute('Smooth');
        smooth = Math.max(0, Math.min(0.99, 1 - smooth));
        sens = this.attribute('Sensitivity');
        if (this.attribute('Invert X')) sens.x *= -1;
        if (this.attribute('Invert Y')) sens.y *= -1;
    
        scrX = Number(this.attribute('Screen X'));
        scrY = Number(this.attribute('Screen Y'));
        forward = new Vec3(
            scrY == 0 ? 1 : 0,
            scrY == 1 ? 1 : 0,
            scrY == 2 ? 1 : 0
        );
        right = new Vec3(
            scrX == 0 ? 1 : 0,
            scrX == 1 ? 1 : 0,
            scrX == 2 ? 1 : 0
        );
    
    
        phys = this.entity().physics();
        sens = sens.scale(0.025);
        if (phys && phys.type() != 'kDynamic') {
            phys = null;
        }
    }
    
    function update(dt) {
        if (!enabled) return;
        let pt = Input.currentTouchPosition();
        if (Input.hasTouch()) {
            if (prev == null) {
                prev = pt;
            }
            let dx = sens.x * (pt.x - prev.x);
            let dy = sens.y * (pt.y - prev.y);
            let vel = getVelFromScreenMove(dx, dy);
            delta = delta.add(vel);
            prev = pt;
    
            if (phys) {
                addAngVel(delta.scale(smooth));
            } else {
                let ent = this.entity();
                let nPos = ent.rotation().add(delta.scale(smooth));
                ent.setRotation(nPos.x, nPos.y, nPos.z);
            }
            delta = delta.scale(1 - smooth);
            prev = pt;
        } else {
            prev = null;
        }
    }
    function signal(name, value) {
        enabled = value;
    }
    
    function getVelFromScreenMove(dx, dy) {
        return forward.scale(dy).add(
            right.scale(dx))
    }
    function addAngVel(vel) {
        setAngVel(vel.add(phys.angularVelocity()))
    }
    function setAngVel(vel) {
        phys.setAngularVelocity(vel.x, vel.y, vel.z);
    }
    
                                          
        
     
    5petersonzachary likes this.
  9. 5petersonzachary

    5petersonzachary Serious Boxer

    Joined:
    Jan 23, 2016
    Messages:
    541
    Likes Received:
    159
    Worked perfectly. Thank you so much!
     

Share This Page