aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Gimeno <parigalo@formauri.es>2019-04-06 13:38:00 +0200
committerorwell96 <orwell@bleipb.de>2019-04-06 13:38:00 +0200
commitc50224e05cfc7a37b9181565024c972446a720ca (patch)
treeb1fd803dfa584b5f1bafd099d22e055cc830d267
parent5738ab46aa5c768b973ef892635fb1642c5f6b9c (diff)
downloadadvtrains-c50224e05cfc7a37b9181565024c972446a720ca.tar.gz
advtrains-c50224e05cfc7a37b9181565024c972446a720ca.tar.bz2
advtrains-c50224e05cfc7a37b9181565024c972446a720ca.zip
Set wagon pitch on slopes
-rw-r--r--advtrains/wagons.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 27df95e..5b15c70 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -503,7 +503,16 @@ function wagon:on_step(dtime)
self.turning = false
end
- self.object:setyaw(yaw)
+ if self.object.set_rotation then
+ local pitch = math.atan2(vdir.y, math.hypot(vdir.x, vdir.z))
+ if data.wagon_flipped then
+ pitch = -pitch
+ end
+ self.object:set_rotation({x=pitch, y=yaw, z=0})
+ else
+ self.object:setyaw(yaw)
+ end
+
self.updatepct_timer=2
if self.update_animation then
self:update_animation(train.velocity, self.old_velocity)