Це відео не доступне.
Перепрошуємо.

3 Ways to Make a Sniper Scope in the Godot Game Engine!

Поділитися
Вставка
  • Опубліковано 15 сер 2024
  • Support the Channel: patreon.com/ChaffGames
    Check My New Course : www.udemy.com/...
    Get the FPS Template Here: chaffgames.com...
    The Guns I use:
    A few weeks ago I was inspired by Garbaj to do a full investigation into the different techniques to make a Sniper Scope in the Godot Game Engine. These are the three that I eventually settled on.
    1. Overlay. This sniper scope is a simple UI overlay that sits over the screen and the camera just zooms in.
    2. Picture in Picture. Using Godot's Viewport feature. We can render a viewport texture to a mesh acting as a Lens on our Sniper Scop.
    3. FOV. We can use a optical illusion to make it seem like the gun is sitting right in front of the PLayers Face, when in reality, it's actually furhter away.
    I'll go over all 3 different ways to make a Sniper scope for the Godot Game Engine.
    Gabaj's Video: • I Have No Idea What's ...
    Mysterious Purple Cat's Video: • How does Apex Legends ...
    Please like and Subscribe! It's truly appreciated
    #GameDevelopment #GameDevTutorial #Godot
    Links to my Socials
    Instagram: / chaff.dev
    Twitter: / chaffdev
    Itch.io: chafmere.itch.io
    Website: chaffgames.com/
    00:00 Intro
    01:40 Basic Animation and Code
    03:45 Overlay Scope
    05:55 Picture in Picture Scope
    11:03 FOV Scope
    13:20 Outro

КОМЕНТАРІ • 31

  • @sammydoodlew
    @sammydoodlew Рік тому +7

    14:00 This can be avoided by animating the gun camera backward instead of animating the gun model forward. I'm pretty sure that's how most FPS games do that method.

    • @Chaff_Games
      @Chaff_Games  Рік тому

      That makes sense. I was wondering how people got around that.

  • @thomasamathew4058
    @thomasamathew4058 2 роки тому +3

    I think I commented this on your channel before.
    But you've seen display panel that a gun has to show ammo, I guess.
    A tutorial on that would be amazing.
    Thanks for your videos.
    You are an asset to the Godot community.

    • @Chaff_Games
      @Chaff_Games  2 роки тому

      Like in Halo? I think I remember that. I'll write it down so I don't forget

    • @thomasamathew4058
      @thomasamathew4058 2 роки тому +1

      @@Chaff_Games I don't know about Halo, but check out devlogs from David RB(Unreal Engine).
      The game he is working on, Arcadian Rift, has guns with Ammo display on them.

  • @nxidplease
    @nxidplease 2 місяці тому

    If anyone is having a problem where they've used MOUSE_MODE_CAPTURED, before adding the ZoomOverlay(CanvasLayer -> Control -> TextureRect) and after adding it it stops working this is due to a setting on the root control node(Hud in the video), go to Mouse -> Filter and select any option other than "Stop" which is selected by default

  • @epiccomediz474
    @epiccomediz474 2 роки тому +1

    This is really cool finally a tutorial on this topic

  • @CROXoDyLE
    @CROXoDyLE Рік тому +2

    perhaps an issue only with my implementation but I noticed when using the first method, if I swap weapons when zoomed in the canvas layer remains fully modulated, because in my implementation the weapon gets removed when swapping weapons so it cant reset the animation. If anyone knows a work around please let me know.

    • @ViktorsJournal
      @ViktorsJournal Рік тому

      I'm not sure if I understand your description completely but before you swap reset it back, it doesn't matter if you play the whole thing while the node is hidden or not since it will still play. Sounds like a good use for an exit method on a state machine when switching guns. :)

  • @ViktorsJournal
    @ViktorsJournal Рік тому +1

    For the 2nd options, instead of script you can probably just use RemoteTransform3D node to update the position?
    Btw, there are no cast shadows wit hthe 2nd scope on the enemies? Or are they hidden below?

  • @DejaimeNeto
    @DejaimeNeto 2 роки тому +1

    yes

  • @jyanjohn7837
    @jyanjohn7837 2 роки тому +1

    Please create a tutorial about bullets

    • @Chaff_Games
      @Chaff_Games  2 роки тому

      Good idea, I've only done hitscan weapons so far, so there aren't any bullets in these weapons, technically. Maybe time to add a projectile weapons 🤔.

  • @cesiupro123
    @cesiupro123 2 роки тому +1

    When I use the picture in picture method, sometimes it works, sometimes it doesn't, and I do it exactly the same way every time. And even if it works, it stops working after I close and reopen the project. The texture isn't loading, the mesh is pitch black. People say it's because both the mesh and the material with the texture have to be set to local. I have both set to local, and the mesh is still black.

    • @Chaff_Games
      @Chaff_Games  2 роки тому +1

      I have had this issue a few times. The only way I've fixed it, is deleting the nodes and making the viewport again. That and, everytime you bring your picture in picture gun into a new scene, you need to set the viewport up again by making the gun "editable" and resetting the viewport texture. It's really fiddly in godot tbh.

    • @cesiupro123
      @cesiupro123 2 роки тому +1

      @@Chaff_Games Yesterday I tried to make it work again, and as usually, it only works until I close the project, then it goes black. Deleting the node works, and what's interesting, the new node has to have a different name from the one I just deleted. Unfortunately, it only works until... you know what. I've been trying for quite some time, and I only found one thing that doesn't stop working after close the project. It's the script that assigns the viewport texture to the mesh, but it has issues. I don't know how to center the texture on the lens so it actually shows what I'm looking at, and not like a bottom right corner only because the texture is bigger than the lens. Also, I need it to work for 2 players (I'm making a split screen game), and when I do that, Player1 sees the zoom camera of Player 2 in the scope, which is quite funny but that's not what I was trying to achieve. Do you know if there is another method? Ways 1 and 3 don't fit my project :/ Thanks for the good tutorial tho

    • @Chaff_Games
      @Chaff_Games  2 роки тому +1

      Definitely sounds like it has something to do with the way resources are handled in Godot. I'm not sure I have a solution for that, sorry.

  • @atomica0914
    @atomica0914 2 роки тому +2

    Woop, woop I'm quite early

  • @MajatekYT
    @MajatekYT 2 роки тому +2

    Wouldn't a picture-in-picture scope method be doable without any performance hit by simply setting the main viewport render target to a texture, use that texture as the main view, then render the rifle and scope on top with a second viewport and have the scope reference the texture that you already rendered to? That way you're only rendering the whole scene once, really. I'm sure you can avoid making it pixelated by animating the field of view to be lower while scoped in instead of just stretching the texture (or having the scope close to the camera and as a result shows the texture stretched to be bigger due to perspectives). But yeah, thank you for the easy to follow tutorial!

    • @Chaff_Games
      @Chaff_Games  2 роки тому +2

      I thought that too but never ended up trying it because I assumed it would be pixelated. 🤔 Maybe I'll give it a go.

    • @MajatekYT
      @MajatekYT 2 роки тому +2

      @@Chaff_Games Now that I had a chance to think about (I made my comment while slightly sleep deprived), it probably won't work as it'd zoom in the view of what's behind the scope as well. Oh well. 😅

    • @Chaff_Games
      @Chaff_Games  2 роки тому +2

      I was having the opposite thought 🤣 I'll have to have a go and see what I come up with.

  • @lukabrasi001
    @lukabrasi001 Рік тому

    hey, i see you're using viewports for weapons, were you able to make the guns in the viewport receive lights and shadows from the main scene? this is the main reason i ditched viewport weapons man and i can't even find a proper solution to this problem

    • @Chaff_Games
      @Chaff_Games  Рік тому

      Works in 3.5 right now, but not in 4. In 4 the shadows don’t transfer over. The trick is to put the world environment in the scene and not in the cameras.

    • @lukabrasi001
      @lukabrasi001 Рік тому +1

      @@Chaff_Games i had it set up like that, but the gun still didn't receive lights from light sources in 4.0, i don't know why it happened though but it made me ditch the whole viewport thing altogether

    • @Chaff_Games
      @Chaff_Games  Рік тому

      The lights need to be on the visual instance as the view model. But like I was saying before, shadows don’t transfer through, so it’s a deal breaker either way.

    • @lukabrasi001
      @lukabrasi001 Рік тому +1

      @@Chaff_Games so the best bet would be using a shader for the weapons that act similarly to viewports

    • @Chaff_Games
      @Chaff_Games  Рік тому +1

      @@lukabrasi001 most likely. i'm hopeful that this gets fixed soon.

  • @bnkm07
    @bnkm07 2 роки тому +1

    how to make the sniper rifle itself?

    • @Chaff_Games
      @Chaff_Games  2 роки тому

      For me, this is just a simple hitscan weapon. So no range or fall. you could follow this video here ua-cam.com/video/xTjMRkDg4Bs/v-deo.html. if you need range and fall then I'm not sure.

    • @bnkm07
      @bnkm07 2 роки тому

      @@Chaff_Games thank u