dluc8461 0 Newbie Poster
Would anyone be interested in writing a small Python script for me.
Approx: 90 lines of code it is required for (Blender Python).  Your help would be much appreciated.

More an Edit than anything. Existing Code below needs to be edited so that the rightKey and the leftKey will rotate around the z(axis) instead of sliding across the x, and y (axis) I need it to rotate only and not slide up and down the z(axis).

EXISTING CODE:

from math import sqrt

def VEC_length(x):
	return sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2])

def VEC_normalize(x): 
	length = VEC_length(x)
	return [x[0]/length,x[1]/length,x[2]/length]

def VEC_mul(s, x):
	return [s * x[0], s * x[1], s * x[2]]

def VEC_add(x, y):
	return [x[0] + y[0], x[1] + y[1], x[2] + y[2]]

def VEC_axisZ(x, y, z):
	return [x[0] + y[0], x[1] + y[1], x[2] + y[2]]

cont = GameLogic.getCurrentController()

fwdkey = cont.getSensor('fwdkey')
backkey = cont.getSensor('backkey')
leftkey = cont.getSensor('leftkey')
rightkey = cont.getSensor('rightkey')

floormove = cont.getActuator('floormove')
GameLogic.addActiveActuator(floormove, 0)

player = cont.getOwner()
speed = player.maxspeed
vec = [0, 0, 0]

if player.flymode:
	shoulder = cont.getActuator('shoulderipo').getOwner()
	playerOri = shoulder.getOrientation()

else:
	playerOri = player.getOrientation()

playerX = [playerOri[0][0], playerOri[1][0], playerOri[2][0]]
playerY = [playerOri[0][1], playerOri[1][1], playerOri[2][1]]
playerZ = [playerOri[0][2], playerOri[1][2], playerOri[2][2]]
print "-------"
print playerZ
if fwdkey.isPositive():
	vec = VEC_add(vec, playerY)

if backkey.isPositive():
	vec = VEC_add(vec, VEC_mul(-1, playerY))

if rightkey.isPositive():
	vec = VEC_add(vec, playerX)

if leftkey.isPositive():
	vec = VEC_axisZ(vec, VEC_mul(-1, playerX), playerZ)
print "PLAYERz"
print playerZ
print "VEC"
print vec
if vec == [0, 0, 0]:
	GameLogic.addActiveActuator(floormove, 0)
 
else:
	vec = VEC_normalize(vec)
	print "NORMALIZE"
	print vec
	vel = VEC_mul(speed, vec)
	floormove.setLinearVelocity(vel[0], vel[1], vel[2], 0)
	GameLogic.addActiveActuator(floormove, 1)



THANKS A MILLION
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.