0 votes

I have an FPS setup more or less like this:

- KinematicBody
    - Spatial (Head)
        - Camera
            - ViewportContainer
                - Viewport
                    - Camera
                    - Spatial (Equipped item)

I have 2 questions here:

  1. Is there another (perhaps more performant) way of preventing equipped items from penetrating walls? I know I could do a raycast and trigger a "push back", but are there other ways?

  2. If this is indeed the best approach, how does one propagate the lighting from the scene to the "equipped item viewport"?

Thanks!

Godot version 3.3
in Engine by (15 points)

I would suggest the following setup:

KinematicBody (Script)
   - Spatial (Head)
   - Camera
       - Spatial (Item)
       - ViewportContainer
           - Viewport
               - Camera

func _ready():
    $Camera/ViewportContainer/Viewport.world = get_world()
    $Camera.culling_mask = $Camera.culling_mask ^ 2 # all layers except separate one for item
    $Camera/Spatial.layers = 2 # separate layer for item
    $Camera/ViewportContainer/Viewport/Camera.culling_mask = 2 # only item layer

This way, the item will belong to the main world, but will be drawn separately. But I'm not sure if this will work + You may have to sync the cameras in space

That was the exact solution, thanks a lot!

While experimenting with this, I found that the animations I had created for my character in first person were only affecting some of the bones inside the Viewport. No idea why, I tried debugging it, but I couldn't even reproduce it with a clean project.

I had to follow your suggestion exactly make it all work, so the only child of the viewport is the camera (which I did have to sync up).

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.