Hello and thanks for reading
So I want to tell a vehicle object (car) to turn towards a waypoint ( I cannot use a steering actuator ).
I think this is what I need to do. I am struggling with the vector/orientation/maths side of things.
- work out if waypoint (.worldPosition ?) is on -x or +x of cars (.localPosition?) axis
- tell car to turn accordingly (the higher -x or +x is, the sharper the turn.
here is some scrappy code that might help clarify (or make things worse). It doesn’t currently work quite as planned:
interest = obj[own['waypoint']]
#print(own.worldPosition[0],own.worldPosition[1], interest.worldPosition[0],interest.worldPosition[1])
new_vect_x = interest.worldPosition[0] - own.worldPosition[0]
new_vect_y = interest.worldPosition[1] - own.worldPosition[1]
new_vect = [new_vect_x, new_vect_y]
print(new_vect)
#print(own.worldOrientation[1])
colRot = interest.worldOrientation.to_euler()[2]
ownRot = own.worldOrientation.to_euler()[2]
#print(colRot,ownRot)
'''if colRot >= ownRot:
turn = 0.1
elif ownRot >= colRot:
turn = -0.1'''
if new_vect > [0.0,1.0]:
turn = -0.1
elif new_vect < [0.0,1.0]:
turn = 0.1
else:
turn = 0