godot icon indicating copy to clipboard operation
godot copied to clipboard

Use collision detection ray to reposition an object already in the scene

Open ryevdokimov opened this issue 1 year ago • 4 comments

Closes: https://github.com/godotengine/godot-proposals/issues/755

Related: https://github.com/godotengine/godot/pull/88511

Currently only works with one object at a time. Multiple objects would probably be a future PR if desired.

Currently does not have a key binding by default:

Works similar to "instant transformations" in that pressing the key initiates the function, and left click commits it.

image

https://github.com/user-attachments/assets/d22159dd-d932-4f22-807c-49f7eea721cd

ryevdokimov avatar Sep 09 '24 02:09 ryevdokimov

I miss a way to offset the object so that it appears outside the ground/wall though. The dragged object's collision shape AABB should be taken into account (if the dragged object is a PhysicsBody3D or CollisionShape3D).

Wouldn't this be resolved by: https://github.com/godotengine/godot/pull/88511?

ryevdokimov avatar Oct 04 '24 15:10 ryevdokimov

Wouldn't this be resolved by: #88511?

Yes, this works perfectly :slightly_smiling_face:

Calinou avatar Oct 04 '24 19:10 Calinou

I suggest binding Shift + G by default to match https://github.com/godotengine/godot/pull/78148.

Done.

ryevdokimov avatar Oct 04 '24 19:10 ryevdokimov

Rebased and modified to work with: https://github.com/godotengine/godot/pull/88511

ryevdokimov avatar Oct 04 '24 21:10 ryevdokimov

Thanks!

Repiteo avatar Oct 14 '24 19:10 Repiteo

Question, in the Dev 4 snapshot blog, this video in the top post is shown, but this shows the collisionshape and mesh fully intersecting the surface (the snapping seems to be at the gizmo origin / anchor?

thygrrr avatar Nov 10 '24 21:11 thygrrr

Question, in the Dev 4 snapshot blog, this video in the top post is shown, but this shows the collisionshape and mesh fully intersecting the surface (the snapping seems to be at the gizmo origin / anchor?

I'm not sure I understand the question, but if you're suggesting that the video in the snapshot post is somewhat misleading to the functionality in the build I would agree. This PR was created separately yet complimentary with https://github.com/godotengine/godot/pull/88511, which was also merged prior to dev 4 build, and the behavior of both is reflected within the dev4 build of the engine. The final position is offset by bounds of the object being positioned.

ryevdokimov avatar Nov 11 '24 03:11 ryevdokimov

Would it be impossible to make the box not clip the conveyor belt, like offset the placement by half the AABB of the box? I think it would be a much more plausible scenario that you don't want the objects to intersect than that they would intersect like shown in the video.

albinaask avatar Nov 14 '24 12:11 albinaask

Would it be impossible to make the box not clip the conveyor belt, like offset the placement by half the AABB of the box? I think it would be a much more plausible scenario that you don't want the objects to intersect than that they would intersect like shown in the video.

This is the behavior in the latest build. This PR was created along with #88511 but were both merged.

ryevdokimov avatar Nov 14 '24 15:11 ryevdokimov

I suggest binding Shift + G by default to match https://github.com/godotengine/godot/pull/78148

As long as there is no solution for implementing #78148 in a way that makes everyone happy (e.g. implementing it alongside the QWER workflow, rather than overwritting/disrupting it), I would suggest to stay close to the current shortcuts?

Maybe use Shift + W or ALT + W, which are much easier to produce with the left hand.

Alternatively, W could be used as a toggle between the translation tool and the Reposition Using Collisions tool. More accurately, it would cycle through the different "Move tools". Blender does that for the selection tools: image

Nodragem avatar Feb 20 '25 11:02 Nodragem

I tried to use this in my own scene and the object I try to snap to colliders is jumping around erratically. I just wanted to check if somebody else has experienced this, before I investigate further...

ratkingsminion avatar Jul 25 '25 13:07 ratkingsminion

That happens when the object is not filtering out its own collision which I've seen before with CSG objects but was fixed in a PR in 4.4. If you're still having that issue with something else, I recommend making an issue.

ryevdokimov avatar Jul 25 '25 16:07 ryevdokimov

I don't use any CSG objects in the scene. I'll make an issue, thanks.

ratkingsminion avatar Jul 25 '25 21:07 ratkingsminion