I don’t know how to code in python, but want to check if my object will behave properly if I use real physics equations directly in Blender Game Engine.
If someone could check the code for its errors I would thank a lot!
I’m not too great with trigonometry, but asin, acos, and atan are arc sine, arc cosine, and arc tangent, while sin, cos, and tan are sine, cosine, and tangent. To use those, just import math and use them with an angle (in radians).
Ok, found out what the problem was. Imported these two moduls and it worked:
from math import *
from mathutils import *
Another question:
winkel = kite.orientation[1][1]
I was told it means, that it gets the angle between the objects y and the worlds y… what does it mean? why 1 and why only 2 numbers? (why not [1][1][1] for xyz?)
and one last question:
i want to programm the following:
if the angle ist 90° to the ground or the world axis, then the speed should be 0.
How can I do this? And not 0 at one, but steadily decrease according to the angle… angle = 0° full power and steadily decrease until angle = 90° no more power.
@SolarLune Ah, yes sorry. I saw asin before in another script with asin and I thought the bge was just renaming it weird.
I could be wrong but I’m fairly certain that own.orientation[1][1] (alone) will not give you any angle.
If you want to find the angle between yours and the worlds axis implement something like this:
import GameLogic as logic
import math
import mathutils as mt
cont = logic.getCurrentController()
own = cont.owner
#Your orientation
ori = own.orientation
#World Y axis
worldY = mt.Vector([0.0, 1.0, 0.0])
#Your Y axis
ownY = mt.Vector([ori[0][1], ori[1][1], ori[2][1]])
#Getting the angle
angle_first = worldY.angle(ownY)
#Converting the angle to degrees
angle = math.degrees(angle_first)
#And saving it as a property so you can use the angle
own["angle"] = angle
own.orientation has a list within a list it looks like this [[1.0, 0.0, -0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
by using own.orientation[1] you get the second list [0.0, 1.0, 0.0] (remember programmers start counting from zero)
and by using own.orientation[1][1] you get the second variable in the second list 1.0