Falling: Set acceleration on step again
authorRui <Rui914@users.noreply.github.com>
Thu, 24 Mar 2016 03:20:00 +0000 (12:20 +0900)
committerest31 <MTest31@outlook.com>
Fri, 25 Mar 2016 14:19:39 +0000 (15:19 +0100)
Commit

65c09a96f41705bb8e75fc5ff4276342be91ed11 "Set acceleration only once in falling node"

has made the acceleration being set only once.
But this has introduced a regression.

Fix #3884.

builtin/game/falling.lua

index 6282f6558e21a2938222a8472169658b8e5e9fde..29d94ae5e86e46868528442a9b8fa557c622403a 100644 (file)
@@ -30,8 +30,6 @@ core.register_entity(":__builtin:falling_node", {
        end,
 
        on_activate = function(self, staticdata)
-               -- Set gravity
-               self.object:setacceleration({x = 0, y = -10, z = 0})
                self.object:set_armor_groups({immortal = 1})
                
                local node = core.deserialize(staticdata)
@@ -43,6 +41,11 @@ core.register_entity(":__builtin:falling_node", {
        end,
 
        on_step = function(self, dtime)
+                -- Set gravity
+               local acceleration = self.object:getacceleration()
+               if not vector.equals(acceleration, {x = 0, y = -10, z = 0}) then
+                       self.object:setacceleration({x = 0, y = -10, z = 0})
+               end
                -- Turn to actual sand when collides to ground or just move
                local pos = self.object:getpos()
                local bcp = {x = pos.x, y = pos.y - 0.7, z = pos.z} -- Position of bottom center point