ID:2419664
 
Hello,

I'm struggling to create smooth animate effects using the animate proc, and I'm not sure if I'm doing it right. If I call animate on an object to move its pixels, and then animate on an object to move its pixels again while it it's still animating, it jumps like the most recently called animate has ended. Is this a limitation of the engine or am I using the proc wrong?

Thank you.
In theory, new animations shouldn't cause a running animation to jump to the end unless the ANIMATION_END_NOW flag is used.
It is hard to describe what happens. I will get a video tomorrow of it happening, but below is the code for both the movement effects and the damage effects if they are needed.

/mob/do_movement_effects(var/turf/old_loc,var/turf/new_loc)
var/pixel_x_offset = -(new_loc.x - old_loc.x)*step_size
var/pixel_y_offset = -(new_loc.y - old_loc.y)*step_size

var/movement_delay = get_movement_delay()

if(client) //Animate the client's camera so it's smooth.
animate(client, LINEAR_EASING, time = 1, pixel_x = pixel_x_offset, pixel_y = pixel_y_offset, flags = ANIMATION_LINEAR_TRANSFORM)
animate(client, LINEAR_EASING, time = movement_delay * 1, pixel_x = 0, pixel_y = 0, flags = ANIMATION_LINEAR_TRANSFORM)

//Animate the mob's movement so it's smooth.
animate(src, LINEAR_EASING, time = 0, pixel_x = pixel_x_offset, pixel_y = pixel_y_offset, flags = ANIMATION_LINEAR_TRANSFORM)
animate(src, LINEAR_EASING, time = movement_delay * 1, pixel_x = 0, pixel_y = 0, flags = ANIMATION_LINEAR_TRANSFORM)


/datum/damagetype/proc/play_effects(var/atom/attacker,var/atom/victim,var/atom/weapon,var/atom/hit_object)
if(length(impact_sounds))
var/area/A = get_area(victim)
play_sound(pick(impact_sounds),all_mobs,vector(victim.x,victim.y,victim.z),environment = A.sound_environment)

var/movement_x = 0
var/movement_y = 0

if(attacker.dir & NORTH)
movement_y = 5

if(attacker.dir & SOUTH)
movement_y = -5

if(attacker.dir & EAST)
movement_x = 5

if(attacker.dir & WEST)
movement_x = -5

animate(attacker,LINEAR_EASING,time = 2, pixel_x = movement_x, pixel_y = movement_y, flags = ANIMATION_LINEAR_TRANSFORM)
animate(attacker,LINEAR_EASING,time = 8, pixel_x = 0, pixel_y = 0, flags = ANIMATION_LINEAR_TRANSFORM)


https://streamable.com/1ufg2

Here is the link to the video.
If you're trying to chain animations to play in sequence, you're supposed to leave out the object after the first call... but that shouldn't matter for zero time animations.

Login to reply.