Hallo zusammen,
ich habe zwei Punkte direkt in der Spielwelt. Nun möchte ich die nötige Rotation für Punkt1 eins ermitteln, damit er in Richtung Punkt2 blickt.
Ich habe es bereits mit einfacher Trigonometrie versucht, allerdings ohne großen Erfolg. Die Richtung passt nicht und Punkt1 dreht sich wild im Kreis, sobald Punkt2 seine Position verändert. Es geht mit erstmal nur um die Y-Rotation.
[expander]
[lua]
local gx,gy,gz = getWorldTranslation(grauerPunkt);
local rx,ry,rz = getWorldTranslation(roterPunkt);
local x = rx-gx;
local z = rz-gz;
local angle = math.atan2(z,x);
angle = math.rad(angle);
[/lua]
[/expander]
Ich stehe echt auf dem Schlauch, vielleicht hat jemand von euch eine Idee
Danke!