#show your code and the error
1 messages · Page 1 of 1 (latest)
which line is 940
and this is the line that crashes it, since it still tries to get the grabbedObject
this code isn't in the first screenshot at all
Yes it's further down in the same code. But in the else statement from the first pic I have isGrab = false. And the second one should only get called if inGrab is true
show all the code
use a paste site #854851968446365696
sure
https://paste.ofcode.org/G4YJSw83atrp5dZHxahqDQ this is the whole thing
the first part is around line 425
FixedUpdate runs before Update in a frame
so if the object was destroyed you're going to still have inGrab == true and the destroyed grabbed object reference
also your code requires the button being pressed before it checks if the grabbed object was destroyed, so regardless of frame timing you could run into this issue
so put the 940 in LateUpdate, would that work?
Side note - this file is quite long and complicated and doing way too much stuff. You should probably move something as complicated as the grabbing logic out into its own separate script
not necessarily because of this issue
That shouldn't be an issue i think, because if you release the button, the grabbed object gets set to null by code (line 496)
As far as I know it doesn't matter after it's compiled right? It's just a matter of preference I thought. I know celeste is basically one big script
it matters in terms of your sanity and ability to maintain the code
and ability for others to read it