Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local laser_speed = 1.5
- return function(fire, power)
- return function(entity)
- local m = vector.new(entity.motionX, entity.motionY, entity.motionZ)
- local p = vector.new(entity.x, entity.y, entity.z)
- local t = p:length() / laser_speed -- time for laser to reach target
- local o = m * t -- offset from original position when laser would have reached target
- local n = p + o -- final position of entity at point when laser would have reached target (good enough?)
- local x, y, z = n.x, n.y, n.z
- local pitch = -math.atan2(y, math.sqrt(x * x + z * z))
- local yaw = math.atan2(-x, z)
- fire(math.deg(yaw), math.deg(pitch), power)
- end
- end
Add Comment
Please, Sign In to add comment