mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-16 16:11:06 +01:00
Add workarround for random velocity change of particles on creation
This commit is contained in:
parent
7578794467
commit
647fecf470
1 changed files with 13 additions and 0 deletions
|
@ -58,6 +58,18 @@ end
|
|||
function mod.update_projectile(self, dtime)
|
||||
if self._removed then return end
|
||||
|
||||
-- Workaround for randomly occurring velocity change between projectile creation
|
||||
-- and the first time step
|
||||
if self._starting_velocity then
|
||||
local curr_velocity = self.object:get_velocity()
|
||||
local distance = vector.distance(curr_velocity, self._starting_velocity)
|
||||
local length = vector.length(self._starting_velocity)
|
||||
if length / distance > 1 then
|
||||
self.object:set_velocity(self._starting_velocity)
|
||||
end
|
||||
self._starting_velocity = nil
|
||||
end
|
||||
|
||||
local entity_name = self.name
|
||||
local entity_def = minetest.registered_entities[entity_name] or {}
|
||||
local entity_vl_projectile = entity_def._vl_projectile or {}
|
||||
|
@ -379,6 +391,7 @@ function mod.create(entity_id, options)
|
|||
-- Update projectile parameters
|
||||
local luaentity = obj:get_luaentity()
|
||||
luaentity._owner = options.owner
|
||||
luaentity._starting_velocity = obj:get_velocity()
|
||||
luaentity._vl_projectile = {
|
||||
extra = options.extra,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue