Is it possible to detect collisions between objects(meshes) in the "Editor mode"?

Say, I have two objects/meshes - a cube and a sphere. In the Editor mode, if I click on the cube (using a mouse) and drag it over the sphere where it overlaps it, is it possible to detect collisions (overlapping/intersecting events are generated) between the two objects?

Essentially, is collision detection possible in the Editor mode and not in the Simulation/Play mode (where it’s possible).

Any pointers would be appreciated. Thanks in advance.

I am afraid overlap/collisions only works at runtime

2 Likes

Collisions and their related events will only work in either Play or Simulate. However, there are ways to integrate something like this on your own but keep in mind it will cost you performance in the editor. This is why I would recommend easy overlap tests like calculating the distance or using a simple linetrace in an already known direction e.g.


You could combine something simple like that with the ‘editor tick’ How to do editor tick via utility widget? - #2 by ClockworkOcean

2 Likes

Thanks. Does it mean that even with the example shown and the “Editor Tick” utility (shown in the video) , the collision/overlap events won’t work in the Editor mode?

For context why I need this — I’m creating a simulator application, where a requirement is to know before the simulation begins, if two objects (actors) are compatible with each other and can be “connected with each other”. e.g. say, if an electrical plug can be connected to an electrical socket - in the editor itself. And then, click on simulate/play to observe their behavior (e.g. the amount of current flowing through the wire).

Yes, the editor tick is just a fancy/hacky way to get a tick event in the editor but it won’t activate any kind of physic sim. This is just started with simulation or play.

The context helps. If it’s just for a ‘is my pipeline connected test’ I would just do an editor utility widget or anything similar and a ‘test connection’ button within. If you hit the button you could get all of actors with a tag (just performance-optimizing to not test unrelated objects) and see their distance which must be close to zero or even add components that must intersect and have kind of a ‘type’ to see if this connection might be valid.

2 Likes

Thanks. Yes, it’s just for “wiring” several objects together. Essentially, creating/designing an electromechanical circuit – in the Editor – and then simulating it. e.g. A plug connected to a socket → a wire connected to the plug on one end and to an electrical appliance at the other end → A sensor attached (connected) to the appliance to measure its temperature. And, so on.

The “connection/wiring” of the circuit is the critical part, where a user needs to know if the objects are actually connected (wired) to each other. Probably, give an indication to the user by changing the color of the object when it’s clicked-and-dragged over to the other object and overlaps/connects to it.

Appreciate your suggestion on the editor utility widget. Will explore on that and see if it works out.

Thanks for your reply.

1 Like

Probably I would use the construction script for something like that. It is always triggered if you move something in your editor scene. If it’s moved I would save my coordinates in my own data class, something like type, position, bounds, etc., and evaluate either here or in a separate step if they connect. Would enable you to have some kind of auto snapping as well.

1 Like

Thanks for this helpul info as well.

1 Like

you can use “Component overlaps actors” in your construction script