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,own.worldPosition, interest.worldPosition,interest.worldPosition) new_vect_x = interest.worldPosition - own.worldPosition new_vect_y = interest.worldPosition - own.worldPosition new_vect = [new_vect_x, new_vect_y] print(new_vect) #print(own.worldOrientation) colRot = interest.worldOrientation.to_euler() ownRot = own.worldOrientation.to_euler() #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