Slingshot Object

Discussion in 'Buildbox 3.0' started by Stryder, Jun 17, 2019.

  1. Stryder

    Stryder Boxer

    Joined:
    Apr 25, 2019
    Messages:
    49
    Likes Received:
    12
    Hey Boxers,

    Does anyone know how to set the slingshot's rotation to a half revolution? Right now the Pool template is set so the player can shoot the cueball in any direction. I want the player to only be allowed to shoot it in a half circle, not full. Is this possible?
     
  2. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    192
    It certainly is but you would need to code something up in the existing node
     
    Stryder likes this.
  3. Stryder

    Stryder Boxer

    Joined:
    Apr 25, 2019
    Messages:
    49
    Likes Received:
    12
    I was hoping it would be something easy but I'll have to look into this. I tried manipulating the code already but unfortunately no luck.
     
  4. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    192
    Is the half circle always the same and always forwards?
     
  5. Stryder

    Stryder Boxer

    Joined:
    Apr 25, 2019
    Messages:
    49
    Likes Received:
    12
    Yes that is correct. I want the arrow to point forward and I want the player to only be able to shoot in a half circle(looking straight ahead). Right now they can shoot behind them(full revolution) and that defeats the purpose of what I want them to do.
     
  6. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    192
    I’ll have a look at that node
     
    Stryder likes this.
  7. Stryder

    Stryder Boxer

    Joined:
    Apr 25, 2019
    Messages:
    49
    Likes Received:
    12
    Thank you so much!
     
  8. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    192
    Change the touchMode function in the Slingshot node to this

    Code:
    function touchMove( point){
        if(!_hit){
            return;
        }
    
        var wp = this.scene().screenToWorld(point.x, point.y);
        wp = new Vec3(wp.x, wp.y, wp.z);
      
        if(wp.z>=0.0) {
            this.setCuePosition(wp.x, wp.z);
        }
    }
     
    Stryder and viking like this.
  9. Stryder

    Stryder Boxer

    Joined:
    Apr 25, 2019
    Messages:
    49
    Likes Received:
    12
    This is fantastic! Thank you for taking the time to figure this out. It works exactly how I wanted to. The only problem now is that the slingshot function doesn't work the same. When you pull back the line, the cueball only moves about an inch. I'll have to try and figure this part out now. Thank you so much again for this!
     
  10. PunkPuffin

    PunkPuffin Avid Boxer

    Joined:
    Sep 27, 2018
    Messages:
    285
    Likes Received:
    192
    @Stryder no problem

    I never had a working version of the node so I just guessed what it did. If you have another version then you really only need to wrap the setCuePosition in the If statement so just take the If from the code above
     
    Stryder likes this.

Share This Page