This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Preventing weapon models from going through walls?

vellisvellis Posts: 14Member

I'm having the following bug with Godot:

In that video, there's a fix for Unity. Does anyone know how to fix this in Godot?

Answers

  • MagicLordMagicLord Posts: 578Unconfirmed

    A second camera should be possible in Godot.
    You can use a raycast node instead in front of the weapon to retract the weapon when it's close to a surface, it is more realistic.

  • SchusterSchuster Posts: 369Member

    What are you gonna do with the gun when you near the wall?....you press gun to down to thighs or chest....yes,do it with raycast and animation :)

  • vellisvellis Posts: 14Member

    That's a highly debatable subject and it really boils down to the theme of the game. If you are doing a "realistic" military shooter, yes that might make sense... but not for my project.

    How would one merge the two cameras in Godot?

  • SchusterSchuster Posts: 369Member

    Spatial-->
    --------camera1
    --------camera2
    merge?...like this?

  • MagicLordMagicLord Posts: 578Unconfirmed

    @Bishop said:
    Spatial-->
    --------camera1
    --------camera2
    merge?...like this?

    I tried two cameras in many ways, but only one camera works at same time in Godot.
    You need to be able to get cameras active at same time or use render to textures for one camera.
    Is there some 3D render to texture example in Godot ?

  • MegalomaniakMegalomaniak Posts: 2,580Admin

    Why over-complicate this whole thing so much?

    PlayerRootNode(Spatial)-->
    --------Locator1(Spatial)
    --------Locator2(Spatial)
    --------PoV(Camera)

    Set locators to where you want them, copy and lerp the camera location between the locators locations as needed?

  • MagicLordMagicLord Posts: 578Unconfirmed

    @Megalomaniak said:
    Why over-complicate this whole thing so much?

    PlayerRootNode(Spatial)-->
    --------Locator1(Spatial)
    --------Locator2(Spatial)
    --------PoV(Camera)

    Set locators to where you want them, copy and lerp the camera location between the locators locations as needed?

    But this does not fix the problem of weapon going through walls when the player walks forward, changing camera location doesn't hide it.

  • TwistedTwiglegTwistedTwigleg Posts: 2,561Admin

    You need a structure like this (I think):
    PlayerRootNode(spatial)
    —> Camera 1
    —> Viewport
    —> —> Camera 2

    Then you’ll need to display the viewport texture in your GUI. Camera2 will only show nodes that are parented to Viewport, so that should allow you to show whatever you want (weapons, hands, etc) even when your up against a wall.

    You can see the 3D in 2D demo and/or the 2D in 3D demo for some ideas on how to go about using two cameras/viewports.

  • MegalomaniakMegalomaniak Posts: 2,580Admin
    edited January 2018

    @MagicLord said:

    But this does not fix the problem of weapon going through walls when the player walks forward, changing camera location doesn't hide it.

    Just because I didn't include the MeshInstance in the hierarcy doesn't mean this wont work, I just left it to figure out as an exercise for the readers.

  • vellisvellis Posts: 14Member

    Any idea on how to fix this on Godot 3?

  • slapinslapin Posts: 62Member

    Ehh looks like something overly overengineered...
    I'd just check raycust and not move into wall. Drawing weapon models via viewport will consume more resources than it is worth.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.