Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomly doesn't slice (this could well be user error) #45

Open
DrBretto opened this issue Mar 30, 2022 · 2 comments
Open

Randomly doesn't slice (this could well be user error) #45

DrBretto opened this issue Mar 30, 2022 · 2 comments
Assignees
Labels

Comments

@DrBretto
Copy link

DrBretto commented Mar 30, 2022

This is coming from the slicer somewhat randomly. I know the triggers are working right because the haptics and the score keeping works. But sometimes, it just randomly doesn't slice. Most of the time, on the same blocks, it slices perfectly fine. It does seem like when there's a bunch of stuff right up in your face is when it fails the most often.

NullReferenceException: Object reference not set to an instance of an object
Slicer.Update () (at Assets/Scripts/Slicer.cs:26)

This happens at the point where it attempts to create the upper and lower objects.

@DavidArayan
Copy link
Owner

Hello DrBretto,

Sounds like a weird projection error. Keep in mind that the Plane has a special math property in that it extends indefinitely in its axis. It's basically defined via a position and orientation (facing direction vector) in 3D space.

Make sure your initial collision detection against the object you're cutting is actually passing correctly. Also make sure the cutting plane is actually initialising correctly, maybe debug-render it in its own coordinate frame to make sure?

Also, that NullReferenceException is weird, perhaps something is happening on the object that you're cutting before the cutter has executed? Could you stack-trace it and see whats happening?

@DavidArayan DavidArayan self-assigned this Mar 30, 2022
@DrBretto
Copy link
Author

DrBretto commented Mar 31, 2022

Hello, and thank you for responding!

Bear with me, I am new to this :)

I have made some progress here. First, I have better luck running this in a FixedUpdate rather than Update. This allowed me to keep triggering the slice until it works on each slice attempt by adding the isTouched=true to the onTriggerStay function as a backup. Because it makes multiple attempts now, it slices just about every time. This is good enough for my purposes, but this is a band-aid. It's still "skipping" randomly and still giving the error message.

I can identify the object that's missing. It happens right when it calls the function that does this:

return obj.Slice(transform.position, transform.up, crossSectionMaterial);

And the next line tries to reference the object that returns., that triggers the error.

I was not able to find the actual Slice method in the files for some reason. It is important to note that when I take the trigger out of OnTriggerStay and just OnTriggerEnter, it might be that it's still working most of the time, but occasionally there's a noticeable delay. It may be working every time, but perhaps sometimes just takes too long to pop up? It's hard to tell.

The objects being sliced are cubes and their only behavior is that they steadily move towards the player. The collisions are being detected reliably, I have the haptic triggers and score updates in the same OnTriggerEnter function (and OnTriggerStay for the haptics as well).

I do not know how to do a stack trace, or what that is :) I am flyin' by the seat of my pants. If you still want me to do so, I can look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants