Guest User

Untitled

a guest
Jan 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #CONSTRAINT
  2. direction = cont.actuators['Direction'] #the constraint actuator
  3. face = sce.objects['Facer'] #the facing object
  4. faco = face.localOrientation[1] #here we are (this gives me a 3x3 matrix)
  5. #but i only want to use the Y value
  6. #I’ve tried out even 0, and 2 but wont work
  7.  
  8. def constra():
  9. direction.direction = faco #this isn't running as it should
  10. cont.activate(direction)
  11.  
  12. import bge
  13. import mathutils
  14.  
  15. sce = bge.logic.getCurrentScene()
  16. face = sce.objects['Facer']
  17. facY = face.worldOrientation.to_euler()[1] #Now we have the Y-axis rotation
  18. facTar = sce.objects['Facingtarget'] #This is the target object we modify
  19. newRotList = [facTar.worldOrientation.to_euler()[0],facY,facTar.worldOrientation.to_euler()[2]] #Now we have a list
  20. newRot = mathutils.Euler(newRotList).to_matrix() #Now we have the matrix we need
  21. facTar.worldOrientation = newRot #The orientation has been modified
Add Comment
Please, Sign In to add comment