Rotti Posted June 6, 2015 Share Posted June 6, 2015 Hello, I have a problem with moveObject. The method only uses relative rotation. I have made a xml file with waypoints and these waypoints have the x, y, z coordinates and the absolute rotation. So now i have to calculate the relative rotation between my object and the waypoint. I came up with this idea: rx, ry, rz = rotation of the waypoint rxx, ryy, rzz = rotation of the object relative rotation = rx - rxx, ry - ryy, rz - rzz This is no code its just the math. But the problem is that if the Y rotation of the waypoint is 359° and the Y rotation of the object is 0° it won't roll one degree to the left. Instead it will roll 359 degrees to the right which looks awful. Can someone help me please? Link to comment
Walid Posted June 6, 2015 Share Posted June 6, 2015 You need to use math functions math.sin() math.cos() math.rad() Link to comment
Rotti Posted June 6, 2015 Author Share Posted June 6, 2015 I dont want the object to look towards the waypoint. I want it to move to the waypoint and to slowly rotate to the rotation of the waypoint so that rx = rxx, ry = ryy, rz = rzz I don't know how sin cos and rad could help me here... Link to comment
Walid Posted June 6, 2015 Share Posted June 6, 2015 I dont want the object to look towards the waypoint. I want it to move to the waypoint and to slowly rotate to the rotation of the waypointso that rx = rxx, ry = ryy, rz = rzz I don't know how sin cos and rad could help me here... Try to do it by yourself then post your code here and i will help u. Also post some SS here Link to comment
Rotti Posted June 6, 2015 Author Share Posted June 6, 2015 I just found this function for c# on the internet. I translated it to lua function calculateDifferenceBetweenAngles(firstAngle, secondAngle) difference = secondAngle - firstAngle; while (difference < -180) do difference = difference + 360 end while (difference > 180) do difference = difference - 360 end return difference end It works. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now