Forum Discussion

xTravyDx's avatar
xTravyDx
Member
10 months ago
Solved

Projectile Launcher not keeping up with movement..

If a player is moving too fast the bullet comes out from the side of the gun but comes out in the right spot when the player is standing still. The faster a player is moving the farther away the bullet launches from. 

-launching projectile from projectile launcher which is grouped to the gun. 

Side question.. I noticed looking through some old gun scripts it says launch (object variable) from (object variable).
Allowing you to better customize your bullets. When I tried to script this way myself I didn't see an option for choosing your own object as the projectile. Is this out dated?





  • You can switch a script to local within the script window. You should see a gear cog icon in your scripts that you can click to edit this.

    The codeblock you're looking for is under the Motion tab at the bottom. It is called Launch From Object.

13 Replies

  • This is due to the projectile running on the server(default). To eliminate this it needs to be running on the player's headset(Local). Typically creators will run a script on the grabbable and reference the projectile launcher, then switch the script to local instead of default and transfer ownership of the projectile launcher reference to the player that grabbed the weapon. Keep in mind that each time a script has a transfer of ownership it resets that script just like when world is started.

    As for your second question this codeblock lets you launch your own projectile but you have to create that projectile object and make a reference to it.

    Let me know what additional questions you have.

    • xTravyDx's avatar
      xTravyDx
      Member

      Ok great thanks I don't quite know how to do that but I have established ownership and am already referencing the projectile launcher on the grabable object script.. so I should be able to figure that out..

      And for the second question I was able to do it successfully making my own projectile object in referencing it but only if I already used that existing script when I try to start a new one I don't even see a code block that gives me an option to change the projectile like the other Code Block. 

      • SeeingBlue's avatar
        SeeingBlue
        Mentor

        You can switch a script to local within the script window. You should see a gear cog icon in your scripts that you can click to edit this.

        The codeblock you're looking for is under the Motion tab at the bottom. It is called Launch From Object.

  • Oh also meant to mention when I had my own projectile it didn't have the issue of shooting from the side of the gun and I did t make the script local wondering why this would be?

    • SeeingBlue's avatar
      SeeingBlue
      Mentor

      I am not sure unless it is related to the size of the projectile. I suspect the issue will still occur under certain conditions, like increased latency.

      • xTravyDx's avatar
        xTravyDx
        Member

        Hmm ok maybe because I was launching from the gun itself rather than the projectile launcher but that came with its own set of complications hence the switch to the projectile launcher. Thanks again you've been super helpful!

  • Okay, so here are a couple of points.

    On World Start, you cannot save the position of the gun using local scripts like this. When a player grabs the gun, the ownership is transferred to the player, and this event gets ran again, which means the values will be set to the position of the gun on grab. I recommend using a reference object to return the gun on release, but that doesn't address the main problem here.

    The when object is grabbed event should contain a transfer ownership to player codeblock so you can transfer the projectile launcher to the player because this doesn't happen automatically just because the launcher is in the gun group, you still have to do that manually. You could also do it at world start and transfer the ownership to the owner of object since the world start event will run when the object is grabbed.

     

    • xTravyDx's avatar
      xTravyDx
      Member

      Ok I appreciate you pointing out that first point too. So when I add the ownership part can I do that in the script I have on the group with the gun and projectile launcher or do I need a script specifically on the projectile launcher itself? I would Imagine i could do it on the same script and just reference the projectile launcher?

      • SeeingBlue's avatar
        SeeingBlue
        Mentor

        Yes, do it in the same script and use the reference to the launcher.