in the figure below you'll see two separate points in time and three object. You can also see the direction object C is facing.
I am trying to replicate a false point of origin for object B at the center of object A, which will then orbit around A based on the direction of object C in the BGE using python. parenting object B and A are not allowed, in fact no parenting is allowed in this example, neither is rotating object B based on the rotation of object A.
how would I accomplish this in the bge using python?
It took me a while to figure out just how to articulate this, and to keep it clear what I want to do. I thanks for any help in advanced.
EDIT: here's what I have so far, this goes on an always sensor to python actuator on object B. It however doesn't set the angle of the object properly.
#------------------------------------------
print("------------------")
import math
import bge
from bge import logic
scene = bge.logic.getCurrentScene()
cont = logic.getCurrentController()
contrlr = bge.logic.getCurrentController()
own = contrlr.owner
obj = scene.objects['C']
#horizontal
x0= obj.worldPosition.x
y0= obj.worldPosition.y
y= 0
x= 0
(dx, dy) = (x0-x, y-y0)
angle = math.degrees(math.atan2(float(dy), float(dx)))
if angle < 0:
angle += 180
#vertical
z0= obj.worldPosition.z
x0= obj.worldPosition.x
z= 0
x= 0
(dx, dy) = (x0-x, z-z0)
angle2 = math.degrees(math.atan2(float(dy), float(dx)))
angle=angle
angle2=angle2+180
if angle2 < 0:
angle2 += 180
print("A1A2",angle,angle2)
#get C's angle from the centerpoint /\
#############################################
#now set the objects angle
import sys
import bge
import random
import math
from bge import logic
scene = bge.logic.getCurrentScene()
cont = logic.getCurrentController()
contrlr = bge.logic.getCurrentController()
own = contrlr.owner
obj = cont.owner
angle2=angle2-90
A=angle*-1
T=angle2
R=own['radius']
obj.worldPosition.x = R*math.sin(T)*math.cos(A);
obj.worldPosition.y = R*math.sin(T)*math.sin(A);
obj.worldPosition.z = R*math.cos(T);
print("tapos",T,A,obj.worldPosition)
hope this edit helps.