Actor following mouse, looking for help

Hi. I was trying to implement a system in wich my model follows the mouse pointer when I click on screen, like diablo, sacred and all this kind of games, the thing is, for testing I divided the screen in 8 parts, like a pizza and when I click in a part with the mouse I set the actor looking for the part and start walking, the problem is out of testing this method is sooo basic and poorly detailed :frowning:

I was wondering if you know and can send me some clues of how to do it better, I was thinking about vectors and using the chess tutorial but I dont know anything about vectors, can anyone tellme more or less how it should work or give me any idea?

So thanks!!

panda3d.org/manual/index.php … 3D_Objects

[Super-fast mouse ray collisions with ground plane)

For just getting the point where a user clicks on a ground plane, the second link markjacksonguy provided is probably the best method. It’s faster than using the collision system and it is endorsed by rdb, who is a Panda3D developer.

For a Diablo type movement scheme you could alternatively use a mouse picking collision detection system, but I would recommend going with the solution provided by rdb.

The collision system would work like this (probably, there are multiple ways to do it).

  1. Create a plane type collision solid in your scene at ground level.

  2. Create a collision ray and add it to a collision traverser.

  3. Use the setFromLens method of the collision ray to have it point from the camera into the scene, through the mouse position.

  4. Get the collision between the ray and the plane. From the collision entry get the position in the world where the collision happened.

  5. Make the character turn toward that position and begin walking.

There are plenty examples around of the code to accomplish this sort of thing. The chessboard sample is one (if memory serves), and the manual page markjacksonguy linked to is another.

Lots of thanks for both, and sorry for not have answered before.
I have looked before the chess tutorial, the fact is that i havnt understand even half of the example, but with some practise and your both explanations now I’m in the right way XD

I have a better character control system so thanks for the help, I’m now perfectioning it, when I finish Ill post it

Thx