#Dash Script Error

1 messages · Page 1 of 1 (latest)

tulip egret
#

anyone know how can i solve this?

#

Dash Script Error

toxic dune
#

Seems like theres probably other logic deleting it, is there any scripts that delete other objects on the enemy?

tulip egret
#

yes i have a script that deletes enemies. but it shouldn't touch my character at all. if an enemy spawns outside my walls, it deletes the enemy and triggers the respawn action. I'm not sure though right now that thing doesn't seem to be working properly. Let me assign that deletion code as well.

tulip egret
toxic dune
#

I would add a debug at least or breakpoint to see if any deletion code is happening. Your game objects wont randomly delete themselves without you calling it

toxic dune
tulip egret
#

I think I solved the problem.

#

I don't think it has anything to do with that script. So yes, that script is probably destroying it, but I was using the trail.Clear() method, which deletes the old trail points after dash in my dash script. When I removed it from the dash script, the error was fixed, but now every time I throw a dash, my old dash points are drawn to the screen.

toxic dune
#

trail.clear wouldnt remove anything from your player hierarchy still. try not to associate random things to solving the issue

#

something is destroying it, or moving it in a place where you didnt notice (probably unlikely)

tulip egret
#

I tried so hard to get this screenshot bruh.

tulip egret
toxic dune
#

trail.Clear doesnt have anything to do with your player deleting

tulip egret
#

so what then? so I don't have any other script that can delete any gameobject.

toxic dune
#

its possible that the trail itself is being hit, or some object. its hard for me to understand the code since the comments arent english.
Did no debugs print at all when your player was deleted?

tulip egret
toxic dune
#

Honestly itll probably be better if you just try to isolate which script the error is in, possibly by disabling components or going through them all to see what logic is happening

#

Maybe you can even put a breakpoint in OnDestroy and try to see the stacktrace to see what called it, though im just speculating here because i havent done this before

tulip egret
toxic dune
#

I would try the OnDestroy, add a breakpoint and try to see the call stack

tulip egret
toxic dune
#

OnDestroy being a unity message, which is called by unity when your object is being destroyed

tulip egret
toxic dune
#

no.. let unity call it because your object is being destroyed

#

then see the call stack so you can attempt to see what calls on destroy

toxic dune
#

should be fine like that, although im unsure if that breakpoint will be called on the { ever. Ive never done that personally

tulip egret
tulip egret
toxic dune
#

did you attach the VS debugger and actually get the breakpoint called?

#

the callstack would be in VS

tulip egret
#

oh nope sorry wait a min.

toxic dune
#

then just add like a Debug.LogError in there, to see the callstack if its relevant

toxic dune
#

Seems fine, try running it and seeing if it ever prints

#

that trail renderer error might be just misleading you, if that somehow is running first and pausing your game before this error prints. Try unpausing once if thats the case

toxic dune
#

is this OnDisable script on the object being destroyed

tulip egret
toxic dune
#

put this OnDisable in a new script and put that on the object being destroyed

#

on disable wont be called if its not disabled/destroyed

tulip egret
#

oh okay

#

okay putted.

#

object is not destroyed just deactivated but why

toxic dune
#

can you show the call stack of that error, click on it and expand the little area at the very bottom

toxic dune
#

Damn I really was hoping that would print out more

#

if you are completely unsure what is destroying/disabling your object, I would start by removing components and trying to replicate it. See where this exactly comes from

tulip egret
#

I suspect trail.clear() I put the trail.clear line in this line in the on cooldown end function, if there is no problem when it is like this, I think the problem is caused by this. When I searched the internet a bit, it said that trail.clear disables the trail and when you call the trail again, objects can be destroyed.

toxic dune
tulip egret
#

yes

toxic dune
#

ah well i guess that solves it.

tulip egret
toxic dune
#

you dont want auto destruct

toxic dune
#

honestly dont know why they made it destroy the object entirely

#

didnt even know this was a thing myself, i dont use trailrenderer much

tulip egret
#

okai solved

#

thx dude tysm

toxic dune
#

lol np, honestly i never wouldve guessed it was the trailrenderer destroying the whole object until you said objects can be destroyed. You probably shouldve checked the api after seeing that 😅