Move player by mouse click

I’m trying to create an RPG like interface for my game. I would like the user to be able to click on the ground and have the player move there. But I can’t find any way to do this. I even bought the the Blender Game Kit and there are no examples that use a mouse.

The closest thing I found was this tutorial:
http://abjedi.free.fr/index.php3?language=en&section=tut&tut=gbtut4
But it requires the camera to be directly on top of the scene and looking right down.

I’d like to have a camera in a normal angled view like you see in an RPG.

any help would be much appreciated.
thank you

This can easily be done but you will need to use python.

Your script will have to be connected to a mouse over sensor and a mouse click sensor. From the mouse over sensor you can get the position of where the mouseray hits objects then make a empty that copy’s itself to that location and have your player trak the empty when it is x distance from it and there u have it :smiley: . Good luck with the game would love to see that type of game made in blender.
:wink:

Hm… but how do you use the information from the mouse over sensor? I looked at the documentation and there are two methods I can call, getRayTarget and getRaySource. Is there something I’m supposed to do with the result of these methods?

the documentation I’m looking at is:
http://www.blender.org/modules/documentation/pydoc_gameengine/PyDoc-Gameengine-2.34/KX_MouseFocusSensor.KX_MouseFocusSensor-class.html

thanks, I really appreciate your help. I’ll put up a tutorial on how to do this if I can get it working.

Oh, by the way, I know I can get the object that was hit from the sensor and move the empty to the object position. But that won’t work for my case since the object to be hit is a large plane. I need a way to find where in the plane the hit occured.

thanks !

I’ve also tried using the tip about using the ray sensor. But i get the same problem. When i check the getHitPosition value it still doesn’t corespond to where the hit acutally occured.

If any one has any kind of demo for this I’d really appreciate it.

thanks!

what about Pos = Ray Name Goes Here.getHitPosition()

Or what about: Mouse click, add object, get position really fast, gamelogic the position of the object, delete object. Another scripts import the position using import GameLogic, set’s position of a empty to that place and using slow parenting to let the player track to the empty. You can also make a script that when it gets a position, is moves slowly (walking) to that position where you clicked. I think with some bricks and python you will reach a lot. :slight_smile:

I’m not sure about how to actually code it, but I’m planning to make a bunch of python scripts within a year. Included some tutorials and another stuff that I’ll put online soon (I hope, when I finally finish my website instead of starting each time over again.)