Help with making a mobile attack button

I know this isn’t directly linked to the courses but I’m really stuck on this so I’m hoping someone can help.

I’m developing for mobile and I’m trying to make it so when I tap on a button, it will deal damage to the closest enemy, I’ve got some code but it’s not really working but I don’t know if there’s a better way to write it all.

With this code whenever I change the range of the weapon in the inspector, it doesn’t work and the range stays the same regardless of what I do.

This is the code: https://pastebin.com/7tt5DbDf

Hi,

Welcome to our community. :slight_smile:

What does that mean? Doesn’t the button work? Log a message into your console when the button was pressed.

This topic was automatically closed after 47 hours. New replies are no longer allowed.

Privacy & Terms