3
$\begingroup$

I would like the mouse to have a custom look like most games and not just the default white. Is there a way I can make an object as the mouse?

enter image description here enter image description here

$\endgroup$
2
  • $\begingroup$ Nevermind I found out how with the power of youtube $\endgroup$ Jun 13, 2014 at 3:33
  • 2
    $\begingroup$ Please include the answer here, otherwise this question is not useful to others. $\endgroup$
    – ideasman42
    Jun 13, 2014 at 5:49

1 Answer 1

2
$\begingroup$

You can use python to do this, for example using essentially the script from this answer by Mike Pan:

from bge import logic, render
render.showMouse(False) # hide default cursor

def mouse2world():
    z = 1 # distance for cursor

    cam = logic.getCurrentScene().active_camera
    vec = cam.getScreenVect(*logic.mouse.position)
    camPos = cam.worldPosition
    projectedPos = [0,0,0]

    projectedPos[0] = camPos[0] - vec[0] * z
    projectedPos[1] = camPos[1] - vec[1] * z
    projectedPos[2] = camPos[2] - vec[2] * z

    return projectedPos

def main():

    cursorObj = logic.getCurrentScene().objects['cursor'] # where 'cursor' is the name of object to use as a cursor
    cam = logic.getCurrentScene().active_camera
    pos = mouse2world()

    cursorObj.worldPosition = pos
    cursorObj.worldOrientation = cam.worldOrientation

To use this, add an always sensor to the camera and enable true pulsing (you can add the sensor to any object, but I think it's more intuitive to put the logic bricks on the camera..). Then connect it to a python controller with the script:

enter image description here

Example file

$\endgroup$

You must log in to answer this question.

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