Hello, after many problems with scripting a First Person mouselook script I decided to just use the logic brick for that part. I have a camera parented to the player (cube). The cube has mouse movement on the x-axis enabled (rotates along the z-axis) and the camera has mouse movement on the y-axis enabled (rotates along its x-axis). The movement of the cube has been scripted with KX_CharacterWrapper.walkDirection.
On youtube and other tuts this mouselook method worked perfectly fine but for me, the camera starts flying away from the cube as if it rotates along a point somewhere. I’ll attach my blend to the post so you can see what I mean. Thanks for any help.apocalypsegame.blend (633 KB)
the scaling, scale objects in edit mode (tab) or hit alt+a to apply scale.
the parenting, due to the player is out of scale the parenting is out of scale as well.
So how to fix it?
select player, hit alt+s
now select camera, alt+p -> clear parent
now with the camera selected hold shift select the cube and ctrl+p -> parent to object.
Done.
import bge
speed = 8
ratio = (1080/1920) # this can be found from render module
RAW_X, RAW_Y = bge.logic.mouse.position
msX = (0.5-RAW_X)*speed
msY = (0.5-RAW_Y)*speed*ratio # scale the y axis to the screen aspect
## Look Around ##
PlayerOBJ.applyMovement((0, 0, msX), True)
CameraOBJ.applyMovement((msY, 0, 0), True)
## Center the Cursor ##
bge.logic.mouse.position = (0.5, 0.5)