I’m trying to do something that should be pretty simple, but having some problems. The goal is to make a simple little platform shooter game. I’ve already figured out how to make a mouse cursor using this tutorial, and I’m sure I can figure out how to track weapons to the cursor with a bit of trial and error.
The problem I’m having is that that particular method of creating a mouse cursor is very unstable. It pretty much only works when the player is ABSOLUTELY immobile. I think the problem is that the cursor is getting it’s position from a ray, cast from a camera, parented to a moving object. And it’s just too much to keep up with in real time.
I made a little example .blend so you guys can see what I’m talking about. The cursor works perfectly if you play from any view besides the camera(although it’s too small to see). But if you play from the camera view, it’s just plain broken any time you move.
What I need is a way to make a cursor that works on a moving camera, and to track to it. THERE’S GOT TO BE A BETTER WAY…
Well for a quick fix you could change the owner.position = mouse.raySource to owner.position = mouse.hitPosition that will make it look alright, but there will be some noticeable problems with the cursor but not as bad as the original, you’ll need to scale your cursor up quite a bit though
I have a version of a mouse cursor that works pretty well. it gets the screen position of the actual mouse cursor and moves a visible cursor till it is at the spot of the mouse cursor. It should work fine for what you are wanting. You would replace the cube with your object, and rename cube in the script to your cursor objects’ name in line 11.
This should work from any perspective. Orientation. The cube is parented to the camera so place your object in the spot of the cube and parent it to the camera as well. Youll see
Another way to do this would be to have an invisible plane in front of your camera parented to the camera that has a certain property; “cursorLoc” or something and use a mouseoverany sensor with “cursorLoc” in the property box. Then do it like scuba said.
cursor.worldPosition = mouseoverany.hitPosition
The only problem this would create is that you would have to use a ray with x-ray to interact with screen objects past the invisible plane.
and Yeah placing objects world Position to raySource doesnt work very well in perspective view