Hi!
I'm making a "side scroller" kind of game. The game is controlled by a keyboard or controller only, but I have a mouse-related bug.
Game looks like that
https://cosmonomicon.art/wp-content/uploads/2024/10/game_example.png
When the player character is near the hotspot, the player can press the InteractionA button to interact with the hotspot. But sometimes mouse-related code deselects the hotspot, and I'm not sure why.
The setup for the scene looks like that:
KickStarter.settingsManager.inputMethod = InputMethod.KeyboardOrController;
KickStarter.settingsManager.hotspotDetection = HotspotDetection.PlayerVicinity;
KickStarter.cursorManager.allowMainCursor = false;
I also have a custom interaction script:
void Update() {
if (Input.GetButtonDown("InteractionA")) {
Debug.Log("click hotspot");
var hotspot = KickStarter.playerInteraction.GetActiveHotspot();
if (hotspot != null) {
hotspot.RunUseInteraction();
}
}
}
The problem is that sometimes I can see a hotspot menu, but the GetActiveHotspot() returns null.
I've investigated the engine code and I've found where exactly problem happens but I'm not sure how to better fix that as I don't want to modify the code directly and complicate updates in the future.
The "problematic" code is in the file PlayerMovement.cs line 86 or something.
if (KickStarter.playerInput.GetMouseState() == MouseState.SingleClick && !KickStarter.playerMenus.IsInteractionMenuOn() && !KickStarter.playerMenus.IsMouseOverMenu() && !KickStarter.playerInteraction.IsMouseOverHotspot())
{
if (KickStarter.playerInteraction.GetHotspotMovingTo())
{
KickStarter.playerInteraction.StopMovingToHotspot();
}
KickStarter.playerInteraction.DeselectHotspot(false);
}
It detects the InteractionA keyboard button as a mouse click and then deselect the Hotspot.
Am I doing something wrong? I would appreciate any help ![]()
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
I'd need to look into this properly, but it may be a bug. The first line may need to include a check for the Hotspot detection method.
Try replacing it with: