So yeah, i was working on making a radial shockwave yesterday, but to no avail. Whenever i think of something, it either fails or totally loses all coherence when i think it through, which kinda sucks. I want the script to launch any near particles away, in a direct line from the users center. The velocity that they're launched with depends on their distance from the center, the closer the faster. I've made it so that they fly faster the further they are away, but i'm unsure as to how i should reverse it to the previously stated function.
The script (for pushing actors) looks like this:
Code:
for actor in MovableMan.Actors do
local avgx = actor.Pos.X - self.Pos.X;
local avgy = actor.Pos.Y - self.Pos.Y;
local distx = math.sqrt((actor.Pos.X - self.Pos.X)^2);
local disty = math.sqrt((actor.Pos.Y - self.Pos.Y)^2);
local dist = math.sqrt(distx ^ 2 + disty ^ 2);
local a = disty;
local b = distx;
local c = dist;
if dist < 100 then
if avgx > 0 then
actor.Vel.X = (c/2) - (math.sqrt(c^2 - b^2)/2);
elseif avgx < 0 then
actor.Vel.X = -((c/2) - (math.sqrt(c^2 - b^2)/2));
end
if avgy > 0 then
actor.Vel.Y = (c/2) - (math.sqrt(c^2 - a^2)/2);
elseif avgy < 0 then
actor.Vel.Y = -((c/2) - (math.sqrt(c^2 - a^2)/2));
end
end
end
I'm pretty sure i need to subtract the above formula (math.sqrt(c^2...)) from some kind of value, but i just don't know which one. If you could help with this problem, it'd be greatly appreciated.