ID:2812847 Aug 17 2022, 2:05 am Making a beam weapon, trying to have a seamless beam animation - while my initial plan of using trig to repeat an icon linearly worked (kind-of), it had little offsets and the like that made it not ideal, so I got to looking at using a matric transform. Something I haven't done since high school and was only barely even touched on. Basically, trying to do three transforms: A) Rotate the icon to the right angle (Turn() to angle - easy part) B) Stretch the icon out along the angle, anchoring it at the start-point (from mid-tile-A -> mid-tile-B) - we'll call this the x-dimension C) Beginning at a 1-dimensional line (invisible), have it expand in the y-dimension so the beam gets thicker. (I might just do this in the icon's animation instead) Here's what I got so far from testing, with some of it taken from other posts I found, the problem being that I don't fully understand what is being done. ``` BeamB(mob/M,turf/T) var/dx = T.x-M.x var/dy = T.y-M.y var/ang = arctan(dx,dy) var/hyp = sqrt(dx**2+dy**2) var/obj/beam/B = new(M.loc) B.pixel_x = dx/2*32 B.pixel_y = dy/2*32 var/newWidth = hyp var/newX = (newWidth - 32)/2 B.transform = matrix().Turn(-ang) var/matrix/m = matrix(hyp, 0, newX, 0, 1, 0) // I don't really know what these numbers do exactly animate(B, transform = m, time = 20, flags = ANIMATION_LINEAR_TRANSFORM) ``` Aug 18 2022, 8:21 am (Edited on Aug 18 2022, 8:27 am) Just came back to say I think I have it figured out! A few little work-arounds, but it does the trick. ``` Beam(turf/M,turf/T) var/dx = T.x-M.x var/dy = T.y-M.y var/ang = arctan(dx,dy) var/hyp = sqrt(dx**2+dy**2) var/x_mod = cos(ang) var/y_mod = sin(ang) var/obj/beam/B = new(M) var/matrix/a = matrix() // Initial Point var/matrix/b = matrix() // End Point var/matrix/c = matrix() // Fade Away a.Scale(0,0) //Begins as a 1D point a.Turn(-ang) //But is facing the right way a.Translate(x_mod*16,y_mod*16) //And begins at the edge of the start point instead of in the middle b.Scale(hyp-0.5,1) //Becomes the length of the beam b.Turn(-ang) //At the right angle b.Translate( (x_mod*16+dx*32)/2 , (y_mod*16+dy*32)/2 // And moves to the halfway point between the start and the finish so the beam "Grows" from the shooter c.Scale(hyp-0.5,0) //Beam fades to nothing in it's "y" axis c.Turn(-ang) c.Translate( (x_mod*16+dx*32)/2 , (y_mod*16+dy*32)/2 B.transform = a animate(B, transform = b, time = 2, flags = ANIMATION_LINEAR_TRANSFORM) spawn(3) animate(B, transform = c, time = 2, flags = ANIMATION_LINEAR_TRANSFORM) ``` 