[video]help Getting The Bullet Following The Rotation

Discussion in 'Buildbox 3.0' started by spicedbeangames, Feb 4, 2019.

  1. spicedbeangames

    spicedbeangames Miniboss Boxer

    Joined:
    Mar 31, 2016
    Messages:
    1,389
    Likes Received:
    596
    Hi all
    I am trying to get the bullet to shoot the yellow ball. As you can see in the video, as the canon moves around, the ball sticks to its current direction. Does anyone know how or where I can get the ball to shoot toward the ball location as it rotates around?

    I tried using the code spawner with the roto shooter but it didnt work, as it was attached to the character and camera movement, and despite trying to play around, the spawn would always happen in the centre of the screen.

    cheers
     
  2. Codifie

    Codifie Avid Boxer

    Joined:
    Apr 17, 2018
    Messages:
    364
    Likes Received:
    190
    I had the same issue with a game I am working on.
    Here is what you will need to do, I think, it seems pretty similar to my issue.
    Go into your Spawn node, you will have to edit the code.

    let pos = this.entity().worldPosition();
    ent.setPosition(pos.x, pos.y, pos.z);

    These two lines of code is what I had to play with. I needed my spawn action to always happen at the same place, so I changed this line of code
    let pos = this.entity().worldPosition();
    to this
    ent.setPosition(0,11,2);

    I then had to change this line of code
    ent.setPosition(pos.x, pos.y, pos.z);
    to this
    ent.setPosition(0,11,2);

    This allowed the spawn action to always spawn at the same location. Now I realize this isn't the issue you are having, but these two lines of code are your key elements that I think you need to play with. Maybe play with the x,y,z values and see what type of reaction you get, which may lead you to a good result.

    One other thing that strikes me as I write this is that your character is basically rotating around an object, so your spawn, if I am assuming correctly, is spawning from your character and is following your character rotation.
    There are these two lines of code in the Spawn node.
    let rot = this.entity().rotation();
    ent.setRotation(rot.x, rot.y, rot.z);
    Both of those lines are dealing with the spawn object rotation, actually this line is based on your character rotation if that is in fact what you spawning from, which I assume.
    let rot = this.entity().rotation();
    These may be the what you will need to play with since your character is always rotating, therefor affecting your spawn object.

    I am just shooting ideas out there for you and hoping something sticks that works for you.
     
    spicedbeangames likes this.
  3. spicedbeangames

    spicedbeangames Miniboss Boxer

    Joined:
    Mar 31, 2016
    Messages:
    1,389
    Likes Received:
    596
    @Codifie cheers I will give it a try and keep my fingers crossed

    Yeah the red ball is rotating around a half ring right now, that I plan to make invisible. The idea being that the red ball fires bullets at the character in the middle
     
  4. Codifie

    Codifie Avid Boxer

    Joined:
    Apr 17, 2018
    Messages:
    364
    Likes Received:
    190
    Hmm...ok, that tells me that the spawned object is for sure using the character rotation, so when firing that explains the strange loop you see. So the y, z parameters are going to be some variable of the character rotation, like a y-50, or a z-75 or maybe even a positive. You will have to play with those numbers. The only concern I have with that type of scenario is that the rotation is constantly changing so maybe a y-z, z-y kind of thing so it is getting reset as the character rotates.
    I'm trying to picture it in my mind, and too complicated for me to just throw a prototype together quick.
    Wish you luck though! Its going to be one of those head scratchers that is going to just take some trial and error.
     

Share This Page