Let's try move_to and a little bit of interpolation

This commit is contained in:
Giov4 2022-10-30 00:23:47 +02:00
parent c28f82cbe0
commit 00e0008976

View File

@ -65,7 +65,7 @@ function ice_spikes:on_activate(pl_name, dtime_s)
minetest.sound_play(sound, sound, true)
self._pl_name = pl_name
obj:set_velocity({x=0, y=self._speed, z=0})
self._spike_base = vector.add(self.object:get_pos(), {x=0, y=1.5, z=0})
else
obj:remove()
end
@ -105,17 +105,14 @@ function ice_spikes:on_step(dtime)
local player = minetest.get_player_by_name(self._pl_name)
self._time_passed = self._time_passed + dtime
self._tick_buffer = self._tick_buffer + dtime
local spike_base = vector.add(self.object:get_pos(), {x=0, y=-0.2, z=0})
local is_in_place = not fbrawl.are_there_nodes_in_area(spike_base, 0.5)
if not player then
self.object:remove()
return
end
if is_in_place then
self.object:set_velocity({x=0, y=0, z=0})
end
self.object:move_to(fbrawl.vec_interpolate(self.object:get_pos(), self._spike_base, 0.3), true)
if self._time_passed >= self._lifetime then
self:remove()
return