Litho line renderer moves towards the camera when attaching a box collider to it

Why does the Litho game object behave in a strange fashion when I attach a box collider to it? It sort of moves towards the camera and then repositions itself back to the original position. Could you please try adding a Box Collider and run the demo scene in the editor once?
This only happens when you use the mouse.
Try connecting and using the Litho device. It works fine.

Hi Rajat,

:thought_balloon: - I tried a variety of configurations of box colliders attached to the Litho GameObject, but I wasn’t able to reproduce the issue you’re describing.

:question: - If you could attach a video or gif of the Scene and Game views exhibiting the problem, that could be very useful, or perhaps just explain more specifically how you have it configured in the Hierarchy?

:thought_balloon: - This might be because of how the Litho Emulator (the thing that lets you use the mouse in the Unity Game window) is implemented. It’s raycasting from the camera to the scene, to determine what to point at, but because Litho points from a different location, the raycasts can be misaligned. This assumption is currently a limitation of the Litho Emulator, and can lead to some strange edge-cases under certain conditions.

:thinking: - That being said, I’m still curious about your case, as I’m unsure whether it’s the same problem…

1 Like

Here - https://www.youtube.com/watch?v=YkzytZRBtDE&feature=youtu.be
I tried applying the collider to the Litho object in the sample scene and it actually works fine. I only have this issue in the sample scene that I created. Strange. It works completely fine with the normal Litho Device.:thinking:

:question: - Could you send me a screenshot of the expanded Hierarchy (especially pointing out which object the collider is attached to)?

:question: - Are you clicking and holding the left mouse button to trigger this issue?

1 Like

No I did not click at all. It happens as soon as the fruit explodes it seems, but sometimes happens without the fruit explosion. Weird.

1 Like

Thanks for the extra info - this allowed me to reproduce the issue :slight_smile:. I have drawn a diagram to explain it:

:bulb: So for the Litho emulator to work, a ray is shot from the camera to the scene based on where the mouse hovers on the Game view. This ray is hitting the top of the collider, so on the next frame, Litho points up a little bit to try to aim at the top of the collider. However, as the collider is attached to Litho, the collider also moves up. When the Litho emulator looks for the next target, it still hits the top of the collider, but that point has moved upwards. This repeats until Litho is pointing upwards at the camera, at which point the raycast from the emulator misses it and hits the ground again, restarting the cycle.

:point_right: - You can fix this by setting the box collider settings as shown below (this ensures the top of the collider is lower than the aiming direction/ ray of Litho, which prevents the issue).

FruitNinjaIssue2

:question: - Could you explain what it is you’re trying to achieve by attaching a collider to Litho? This could be an important design point for the SDK; does the point below explain an alternative method to achieve the same thing?

:point_right: - If you want the fruit to respond to the Litho pointing at it, you can attach a Manipulable component to the fruit prefab, then in your explosion script, subscribe the explode function to the OnManipulatorEnter event of the attached Manipulable. This is demonstrated in the docs here (change OnManipulatorExit for OnManipulatorEnter)

Let me know how you get on :slight_smile:

The reason why I am attaching a collider to the Litho is because I want it to act like a sword that could possibly slice through any game object in the scene. I could not figure out a way to implement a cutting algorithm so instead just used exploding fruit assets that had that cool explosion effect. I just called the Explode() function as soon as the Line renderer collides with the fruit.:stuck_out_tongue:

Is the Litho SDK available for open source contributions on GitHub? Would love to make some contribution to Litho in terms of development. There are some more ideas that I have actually.

Hi Rajat

:question: - Have you tried the method I mentioned above involving the Manipulable component?

:bulb: - The reason it’s designed this way is that attaching a Collider to the Litho will interfere with other interactions (such as picking objects up) - although your initiative is great for the fruit-slicing application you’re developing :slight_smile:

:point_right: - The SDK currently isn’t available for open source contributions, however you are more than welcome to open new topics here in the forums to post any interesting or useful scripts you make!

2 Likes

No I didn’t go for the Selectable component because attaching the collider seems to work fine when testing with the actual device. Besides using the Selectable component won’t be great for the slicing effect that I want. It will be like just shooting the fruits basically. Thanks for the suggestion though. Sorry for the late reply. Got busy with some other work. :slight_smile:

2 Likes