Rotate Character to match camera's orientation

I’m in the early phases of making a 3D platformer and I’m still relatively new to scripting and especially new to Python, but the method I’m using was recommended on an old thread and I thought it would work. Basically I get the player’s rotation on the z axis and then set it to the camera’s z-axis, but what ends up happening is the camera and the player spin uncontrollably. The lines in question are 24-28 and 85-87. I used a couple resources from people on this forum, a modified version of Mobious’s 3rd Person Camera and a modified version of Captain Oblivion’s 3rd person shooter script. I’m also using the models and test level from Captain Oblivion until I get real models and animations.

Blend File:https://www.dropbox.com/s/htsfiqwpl8hrhfv/ambitious%20project.blend

Code:


l = bge.logic
o = l.getCurrentController().owner
scene = l.getCurrentScene()
cam = scene.active_camera
camrot = cam.orientation.to_euler()


#skip to 85-87


if keys[forward] == 2: #the inputs work fine, I used a different system than Captain Oblivion though
	moveVec[1] += 1
	ori = o.orientation.to_euler()
	ori.z = camrot.z
	o.orientation = ori



Hope someone can help!

Thanks Mobious, I’ll get on that