Alright, I’ve been hacking away at this problem for some time now to no avail. In my current project, a sidescroller-shooter, I would like to incorporate a mouse-aiming system similar to the Stickman-Sam internet game. So far, I’ve been able to recreate it perfectly in orthographic mode, but when I switch to a 3d view I run into some problems. The cursor snaps to the location of the camera, and if I constrain it’s location to the same x plane as the character, it stays pinned in the same Y-Z plane as the camera. This is a major issue, since many of the gameplay mechanic rely on a 3d viewpoint.
The code I’m using is similar to a “Track-To” file I downloaded ages ago from Gameblender, since I thought it would be usefull in the future. I think the issue is that it snaps the cursor to the raySource of a Mouse “Over Any” sensor. I’m providing the code, for more insight. Any suggestions?
import Rasterizer as R
cont = GameLogic.getCurrentController()
own = cont.owner
mPosi = cont.sensors[“MousePosi”]
lmb = cont.sensors[“lmb”]
Start mouse position at center of game screen
if own.init == 1:
own.init = 0
Move cursor to mouse position
if mPosi.positive and lmb.positive:
cursorPosi = mPosi.raySource
own.position = cursorPosi