I’m using UnityEngine.EventSystems
for my interaction system, implementing all IPointer
interfaces. It works almost perfectly. I have a round cursor showing up when I’m hovering over interactable object.
Reason i say almost is that at high speed (i have a physics forces driven plane) interaction events aren’t reliably called. Tbh speed of my vehicle isn’t even that big asit breaks at around 30-40 velocity magnitude. After that my interaction cursor starts flickering when aimed at doors etc and sometimes button interaction wont be called, not to add that all grabbing mechanics simply break.
I might add that in order to make this whole interaction system working i needed to add simple script from internet, which basically fixes known issue with EventSystem
interactions when using CursorLockMode.Locked
.
Here is the code, it runs before EventSystem
in scripts hierarchy:
public UIManager manager;
void Update()
{
if (manager.ESCMenuState == UIManager.UIState.closed)
{
Cursor.lockState = CursorLockMode.Confined;
}
}
void LateUpdate()
{
if (manager.ESCMenuState == UIManager.UIState.closed)
{
Cursor.lockState = CursorLockMode.Locked;
}
}