Lejo wrote:I tried to generate a trial of smoke from a player to another position.
Code: Select all
local pos = player:getpos() ; pos.y = pos.y +1
local goal = {x=0, y=0, z=0}
local dir = vector.direction(pos, goal)
local dis = vector.distance(pos, goal)
minetest.add_particlespawner({
amount = 15*dis,
time = 1,
minpos = pos,
maxpos = pos,
minvel = dis,
maxvel = dis,
minacc = dir,
maxacc = dir,
minexptime = 1,
maxexptime = 1,
minsize = 15,
maxsize = 20,
collisiondetection = false,
vertical = false,
texture = "tnt_smoke.png"
})
The smoke should spawn at the player and disappears at position, but I don't know how to set
minvel and
maxvel.
Can someone help me?
These are velocity vectors. As far as I can tell from your code, the particles need to make the distance dis (which is a scalar) within 1 second. Because minvel and maxvel are vectors, they tell the velocity and the movement direction at the same time.
You can think of this as follows:
In one second, the particle moves exactly one time the vector's length along the velocity vector, so it's position is then vector.add(pos, vel) (in Minetest semantics)
After 2 seconds, it's vector.add(pos, vector.multiply(vel, 2)) a.s.o.
Because your particles have to move along the vector vector.subtract(goal, pos) in exactly 1 second, your velocity vector (minvel and maxvel) is simply vector.subtract(goal, pos) (which is equal to vector.multiply(dir, dis))
(if you change the expiry time to something different (lets name it 'time'), it will be vector.multiply(vector.subtract(goal, pos), 1/time) )
Acceleration is a vector as well. The procedure is the same like for the position and velocity.
new_velocity = vector.add(old_velocity, vector.multiply(acc, delta_time))
You probably don't want your particles to change their velocity at all, so you should set minacc and maxacc to {x=0,y=0,z=0}.