Hey everyone! I hope I can get some help with this issue, because it is BOGGLING my mind. I have created an RTS (starcraft-esque) game for Newgrounds’ Pixel Day 2022 (it is called BitBase if you want to try it out and get a better idea of the issues I’m having lol, but this post is about one issue in particular).
**Main Issue: ** When I run the game in Unity, I have 5 ‘peons’ in the scene, along with a few resources for them to gather and a central node, and I am able to left-click and ‘select’ those units without any issue, but new units spawned in WILL NOT activate their selected function this way. The way the game functions right now, you can drag and select units, which works for all as I have a script on a boxCollider and lineRenderer that does all of my detection for that. Also functioning is a UI script that pops an info panel when a unit is left-clicked (not click and dragged)…
Troubleshooting steps I have taken;
- I have broken down the units that are in the scene bit by bit and they are NO different than the units being instantiated (they are just prefabs that I dragged into the scene, but the same prefab being instantiated).
- Changed my Ui script to access the clicked unit script (using PhysicsRaycast2D then getting the hit collider’s Unit component and tried to FORCE the selector active that way… to no avail)
- Tried an OnClick function on the Unit monobehaviour script
- There are no colliders blocking the unit, the units have rigidbodies, they are on the proper detection layer and it IS detecting the unit being clicked, because it is popping the UI info, but somehow getting lost in actually accessing the Unit… :S
There is probably something super simple that I’m missing or a conflict in the UI scripts possibly, but I’m at my wits end here. Also, I am self taught, so I apologize if any of my terminology is improper; if there is any confusion please let me know and I will try to provide more info or screenshots!