How to change the mouse cursor on "mouse over"?

Hi, i am trying to create a sort of a cursor system, which is found in the adventure games. :slight_smile:
(i.e. change the cursor when over an object)

I did a search in the forum and found a nice demo called “curser.blend”, which was very helpful to me(atleast to understand how to display a cursor), but now I am stuck with the actual changing of the cursor image.I have the following setup on my “system_cursors” scene.

In front of the camera I have “Plane.002” which is used to receive the coordinates of the mouse, process them with the “cursor2” script, and send them to the “Plane” object. Which is simply a plane with a texture of a cursor on it :slight_smile:

The script is the following:

import GameLogic
g = GameLogic
cont=g.getCurrentController()
own=cont.getOwner()

pos = cont.getSensors()[0].getRaySource()
cont.getActuator(“x”).getOwner().setPosition([pos[0]*own.pluss,pos[1]*own.pluss,0])

if GameLogic.Cursor == 2:
g.addActiveActuator(cont.getActuator(“act2”),1)

print(GameLogic.Cursor) # this is used to see if i actually get GameLogic.Cursor==2 when over the object

GameLogic.Cursor = 1

Wwhen i get the global variable GameLogic.Cursor == 2, the script should go to actuator “act2” which replaces my mesh with “Plane.001” - that’s another plane with another cursor image on it. But it doesn’t O_o
I have made a script which changes GameLogic.Cursor=2 when mouse is over the object i need.
I.e. it enters the “If” statement, but i dont understand why it doesnt continue to add the “act2” actuator.

Any ideas how to change the cursor when over an object?Or how to fix this?
Thanks in advance :slight_smile:
Excuse me for my English… and for the long post.

Hello…

I’d like to help… but…
Could you post the blend file… I think I understand how the script goes but I’d like to see it running. I’m not sure if it’s a syntax problem or another thing.

Ju

sure

http://www.4shared.com/file/8486512/6753b5cd/cursors_test3.html

:slight_smile:

Hey bLaf

Sorry. I tought I could help but can’t.
I’m a bit lost in the .blend file
I know a bit of python and GameLogic, but I did not understand how this thing could work out. I didn’t even understand how you got the first plane to follow the mouse.:o So getting it to switch mesh is trickier for me

I hope someone else will have better luck.

  • You forgot to pack data, so the textures for the cursors don’t show up. Makes it very hard to determine what is what.
  • Please pack data and additionally get rid of everything that’s not being used (scripts, bricks, props, code, objects). The stuff not being used is just a distraction, and it makes the .blend more confusing than it actually is.
  • From the little time that I gave this, there seems to be one obvious problem (maybe I just don’t see what you did, but anyway…). I don’t see you setting a mesh anywhere for the edit object actuator on “plane”.

here’s a packed blend without the unnecessary stuff.

http://www.4shared.com/file/8492999/8340a1ce/cursors_test4.html

now the cursor goes LAAARGE …(no replacing though)

The reason your not getting a proper replace seems to be because of the “Use Blender Materials” option being enabled.

If you turn off “Use Blender Materials” the replace will work.

I don’t know what’s causing the size issues, but you can fix that too by simply going into edit mode for “c2” and making it smaller. Play around with that until the replace size is to your liking.

hey, thanks! :slight_smile:

but if i need to have “Use Blender Materials” turned on?it seems kind of an illogical solution to me…

Well yea, but keep in mind that “Use Blender Materials” was only implemented a couple of versions ago. It’s not all that stable to begin with.

Just stick to UV textures, if you do things right and paint some nice looking textures, you really don’t need the “Use Blender Materials” option.

as it stands as long as your not trying to implement normal mapping or other glsl function you don’t really need blender materials

thanks again!

for this project i think we aren’t going to use normal mapping because we’re looking for a more cartoon-ish style… in the future, if we make something more detailed, i will have to find another way to change the cursor…(or…to hope this strange bug will be fixed).

now… i have to figure out, how to change the cursor back to the original, when not over the object :smiley:

===>

/figured it… it was simple./

here’s a .blend if someone else needs

http://www.4shared.com/file/8501532/339e7792/cursors_test5.html


sensor = cont.getSensor("mouseoversensor")
actuator = cont.getActuator("replace mesh") # Set it to replace back to c1.

if not sensor.isPositive():
    g.addActiveActuator(actuator, 1)

yeah, thanks
i figured it out myself! :smiley:

just to notice, on the last blend, i forgot to resize the cursor so if anyone downloads it, may shall have to resize it himself :smiley:

ane one more thing to notice(for newbies like me): the second plane of the cursor will appear as a miniature plane when the .blend is [p]layed; it just has to be moved away from the camera.

thanks again, Social, jessegp for the info, and Juego for trying :slight_smile: