#Bug with placing towers

1 messages Β· Page 1 of 1 (latest)

stuck fractal
#

Heya, I got a problem with placing towers in my TD game. I have a script that checks if it's buildable there but when i spam click idk why it's just placing the tower.

dire solstice
stuck fractal
#

Thanks

#

<@&823670121133768714> Does anybody have a fix?

worn meteor
#

checking 1min

#

Just want to confirm. If you don't spam it works properly or you still have an issue then?

#

If it does work when you don't spam then destroy might be the issue try replacing it with DestroyImmediate

stuck fractal
#

okay

#

Ty I'm gonna try that

#

Sometimes it works and sometimes it doesn't

stuck fractal
#

<@&823670121133768714> Anyone?

wicked thistle
#

No clue, try restarting unity or your computer

#

Are you sure it's a unity issue and not a script error?

astral sable
#

Sorry if you don't mind could you rephrase the question

mild prairie
#

@stuck fractal then don't spam πŸ’€ πŸ˜‚

#

Jk

#

But

#

I don't really understand why it wouldn't work

#

I didn't look at your cs

stuck fractal
#

Sorry i just really need to get it fixed

mild prairie
stuck fractal
#

okay thanks

stuck fractal
stuck fractal
#

I fixed it!

#

It had to do with the OnTriggerEnter2D so i changed it to OnTriggerStay2D

boreal dawn
boreal dawn
#

OnTriggerStay is only called every fixed update so it's not really great for a lot of logic, there's also edge cases where it can get called twice or worse, not get called while you're in the collider