0 votes

Hello,

I encounter a small problem.
I'm trying to learn Godot by doing a small 2D RTS. One of the feature is to be able to place a element in the world if there is no object below.

Expected:
Moving a "building" above a "rock" should add a red box to the building to indicate it's not possible to drop it

If the camera is a its initial position, everything works fine:
enter image description here

But if the camera change its position, the event doesn't trigger at the "rock" position:
enter image description here

It's like, the body is bind to the viewport, I'm not sure if I miss something here or if all my code is wrong but I would like to habe some help.

Here is the code if you want to take a look: https://github.com/hyoa/gidobuild_godot
Don't mind the anarchy in the structure of my project :(

asked Sep 6, 2019 in Engine by hyoa (15 points)

1 Answer

+1 vote
Best answer

I think this happens because you instanced dragged house under your UI layer canvas layer, which IS pinned to the viewport. You should instance the house under the world so that it will be rendered at correct position and collision checks will line up.

answered Sep 6, 2019 by Zylann (22,041 points)
selected Sep 7, 2019 by hyoa

Thanks ! it was indeed that.

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.