Screen 1
When I hover over and click the exit button it works, but when I am doing the same thing with the start button it shows an error:

line 9, in main  KeyError: 'requested item "startGame" does not exist'

Screenshot 1

Screen 2
In the second screen, when I deactivate all sensors and actuator of the exit button, the start button is working properly.

Please help me.

Screenshot 2


2 Answers 2


I strongly suggest to separate hover from activating. This makes the implementation much simpler.


There are two different designs to achieve hover:

Individual Hover

Each objects handles the hover by itself. This is fine when each object has a different way to present hover


Mouse Over Sensor -> AND -> Action Actuator Mode:Flipper Action: Hover.Action

Hover Controller

One object the Hover Controller handles all hover and performs the according actions. Due to it's dynamic behavior you need to Python to do that.

Mouse Over Any Sensor -> Python

import bge

COLOR_HOVERRED = [1, 0, 0, True]

controller = bge.logic.getCurrentController()
storage = controller.owner

sensors = controller.sensors
mouseSensor = sensors[0]

if mouseSensor.positive:
    hoverredObject = mouseSensor.hitObject
    storage["last hoverred"] = hoverredObject

    storage["original color"] = hoverredObject.color.copy()
    hoverredObject.color = COLOR_HOVERRED
    lastHoverred = storage.get("last hoverred")

    if lastHoverred:
        lastHoverred.color = storage["original color"]

This code is based on your sample. When you want to hover certain objects only you can setup a filter property (e.g. "hoverable") at the mouse sensor and give each Object an according property "hoverrable".

Button Click

The button click is very simple and you do not necessarily need Python

mouse over sensor + mouse click sensor -> AND -> actuator

  • $\begingroup$ thanks for support problem has been resolved but another problem generated and i am trying to resolve that $\endgroup$
    – Aman Singh
    Commented Nov 23, 2017 at 15:16

Mouse over text does not work, instead use a plane invible and parent it to the text (child), to make parent use Alt+P.

enter image description here

The plane needs to be an actor to be detected.

enter image description here

Use the logic on the planes:

enter image description here

And to change the color use cont.owner.children[0].color = [1,1,1,true].

When you use module execution mode it pass the controller to the function.

#Note that there is no imports

def start(cont):
    l_click = cont.sensors['MouseStart']
    m_over = cont.sensors['MouseStart1']
    game_actuator = cont.actuators['startGame']
    if l_click.positive and m_over.hitObject:

def exit(cont):
    l_click = cont.sensors['MouseExit']
    m_over = cont.sensors['MouseExit1']
    game_actuator = cont.actuators['Game']
    if l_click.positive and m_over.hitObject:
  • $\begingroup$ thanks for support problem has been resolved but another problem generated and i am trying to resolve that $\endgroup$
    – Aman Singh
    Commented Nov 23, 2017 at 15:18
  • $\begingroup$ Could you describe the problem that still persists? $\endgroup$
    – RPaladin
    Commented May 15, 2021 at 1:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .