[UNITY 2022] Unit doesnt spawn

If u have trouble with unit spawing in unity 2022, try this code:

public void OnMouseDown()
{
    if (!Mouse.current.leftButton.wasPressedThisFrame) return;
    if (EventSystem.current.IsPointerOverGameObject()) { return; }
    if (!hasAuthority) { return; }
    
    CmdSpawnUnit(unitSpawnPoint.position);
}

This worked for me, hope it work for you

2 Likes

It really works, and I cannot spawn units with the former. Thanks!

1 Like

Privacy & Terms