Having a bone follow camera rotation

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.

Any ideas?

Cheers!-YA

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?

Wait! Do constraints even work in the bge?

Haloo?

Anyone there?

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!

How would I go about separating bones from the regular armature?

Or am I seperating the mesh?

BTW I tried it with the bones and the whole object was moved intstead of just the areas the upper body controlled.
:frowning:

I think you need this thread:

How can i copy orientation from object to bone of the armature?

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.

I hope this does not sound to complicated.

How would I get the armature to play animations depending on how I have rotated it?

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.

Here are some ideas how to do that:

I hope it helps

try parenting the bone to the camera, select the bone, shift+select camera, Ctrl p…i would think that that is all that is needed

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!

Wait isn’t there a simple script to get the x and y coordinates of the mouse onto the screen?

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




Quadruple posting is always a horrible idea, but,
bump

cont.owner[…]

Oh my god.

This is low… Even for me… :eek::o:o:o

Ughhhh… My brain hurts now…

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.

Anyone out there? Please?

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.

Blah. Yeah I’ll have to find an example because I’m having a hard time comprehending this…

UGH! I still don’t understand!
Sorry to sound thick and all, but I’m truly having a hard time grasping this.