Glitch with spawning

Hello,
I’m hoping someone can help me out with a slight glitch I am having. Here is the problem. When I click on the unit spawner it doesn’t always spawn a unit. I’ve tested the following:

  1. moving the mouse between clicks gives me the infrequent spawning.
  2. not moving the mouse between clicks leads to nothing ever spawning.
  3. the location of the click (so long as its on the spawner box) has made no noticeable diffence. If a unit doesn’t spawn clicking Spot A, and a unit doesn’t spawn clicking Spot B, clicking Spot A again could spawn a unit.
  4. I have added three lines of debug code to the following spawner code.
 public void OnPointerClick(PointerEventData eventData)
    {
        Debug.Log("Clicked");
        if (eventData.button != PointerEventData.InputButton.Left) { return; }
        Debug.Log("Clicked on a Spawner");
        if (!hasAuthority) { return; }
        Debug.Log("Clicked on my Spawner");
        CmdSpawnUnit();
    }

There is never a time where only one debug is written to console. If a unit spawns, all debugs are written to console. If a unit doesn’t spawn, nothing is written to console. This leads me to believe the issue isn’t with this code.
5. I thought maybe something “invisible” could be blocking the spawner, but I don’t see anything in the hierarchy or on screen that could be blocking it.

Any ideas would be very much appreciated. Thanks!

3 Likes

@Marc_Carlyon has found out that I missed one little thing (which was removing the graphic raycaster from the canvas) so I’m going to re-do the the lecture after this one and add the fix in there

5 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms