Hi, all! I am making a two-player fps. I would like it so that the user, P1 or P2, will have a first person view, and the other will see that character. I have all animations set up and the camera placed. I just would like to know how I could have the upper body bone follow the camera’s rotation like in Halo and other multiplayer shooters. I tried the copy rotation constraint, but to no avail.
Haha I actually just fixed it! Now I have another problem- The roataion works fine when I manually rotate the camera in the 3D view, but not in the game engine when I am running MouseLook. Does MouseLook actually rotate the camera? If not, how do I make it so?
Contraints work on the bge, only not with armature! This is a problem many of us are looking a solution. In my case I’m waiting for the ragdoll system to work perfectly. Since the bones follow the rotation an object imposes, you can the contraint a bone to the mouselook, and have the desired effect.
But since a game is not a simulation all the time, you can fake it:
Make the upper body a different object, and then parent it to the camera, then parent the cam to the lower body!
beside that, you can add actions to your armature that make the motions you need for moving the camera.
Parent the camera to the end bone.
Control the armature with the mouselook script.
If the actions for x-mouse motion and y-mouse motion have separate channels (they do not share any other channel/bone) you can play them both at the same time.
Have a bone performing the rotation around X-axis (up-down). Make sure in the action window only the channel with this bones name exist. You can remove other channels by selecting (<B> , <X>). Give the action a name e.g. UpDown. Make sure you have a reasonable value range (frame 0 = 0°, frame 90 = 90°, frame -90 = -90° etc).
Have another bone with the rotation around the Z axis (left-right). Make another action, with name LeftRight. The same thing, make sure you have channels for this bone only.
Make sure all other actions you want to play do NOT include the channel for this two bones.
now the logic:
As the actions do not share channels you can play them at the same time.
I suggest to use the property mode of the action actuator .
For one rotation do
add a float property “upDown” with 0.0
add a Property sensor, Mode: changed, prop: UpDown
connect to
an AND controller
connect to an Action actuator, Mode:Property, Action: “UpDown”, prop: “UpOwn” (not frameProp)
Do the same with another property leftRight and the action “leftRight”
If you change these properties, the armature will rotate the bones according to the property values.
Now you need logic to change the properties with whatever sensors keyboard, mouse etc.
Alright! I think I have Everything set up! Now I think I’ll use the event mapper and take the mouse’s x and y coordinates, multiply them by 90, and then map them to the property! Yayyy!
AaAaAaAaAaAaARGHHH!!! I wrote the script, but now the console says:
Python script error from controller “cont1#CONTR#3”:
Traceback (most recent call last):
File “XandY”, line 15, in ?
TypeError: object does not support item assignment
This is the script:
from GameLogic import*
from Rasterizer import*
import Rasterizer
from math import*
Rasterizer.showMouse(1)
cont = GameLogic.getCurrentController()
own = cont.owner
sens = cont.sensors
move = sens['Movement']
Height = getWindowHeight()/2
Width = getWindowWidth()/2
cont["LeftRight"] = move.getXPosition()/10# line 14
cont["UpDown"] = move.getYPosition()/10 #line 15
I need to find a way to make it so that the values in the window are absolute, no matter how big or how large the screen is. Otherwise, some computers won’t be able to play because it will either be over sensitive or they won’t have any wange of motion.
I’m at my wits end here, and I need to call in a major Rasterizer buff.
absolute is what you already have 1 Mouse unit = 1 Action unit regardless of the screen size.
relative is when you take the screensize in account.
relativeValueX = mousePosX /(screenWidth/2)
results in
-1 = left border of the screen
0 = middle of the screen
+1 = right border of the screen.
But this means the mouse sensitivity depends on the screen size.
I think what you really need is to ensure the mouse does not leave the window (as used with mouselook).
That is simply done by resetting the mouse cursor to the middle of the screen after reading its current position. In that case you have to add the mouse position to the previous value rather than using the value direct.
I think there is an example in the EventMapper showing both methods.