Changing TimePosition of an AnimationTrack doesn't detect event markers?

  1. What do you want to achieve?
    I want to make it so whenever the event markers “HitStart” and “HitStop” are reached in an AnimationTrack, the script will print that they have been reached.

  2. What is the issue?
    I have a local script that detects when the animation events are reached, and another one that changes the TimePosition of the animation so it won’t slow down when the player’s framerate drops. (Yes that’s a real thing and it’s annoying)
    For some reason, changing the TimePosition of the animation affects that, making the events go undetected.

Marker detection script
for i,Animation in pairs(Animations.All) do				
	Animation:GetMarkerReachedSignal("HitStart"):Connect(function(Distance)
		print("START!!!")
	end)

	Animation:GetMarkerReachedSignal("HitStop"):Connect(function(Distance)
		print("STOP!!!")
	end)
end
TimePosition changing script
RunService.PreRender:Connect(function(DeltaTime) -- I doubt it has something to do with the PreRender event, but I'll mention it just in case!
	for Animation,Time in pairs(Anims) do
		Time += DeltaTime*Animation.Speed
		Anims[Animation] = Time
		Animation.TimePosition = Time
	end
end)

With TimePosition changing: https://gyazo.com/10ed7d97eb35d7bf654ae7dfbef618f9
Without: https://gyazo.com/3e636feba7182829ec645f68618998e1

  1. What solutions have you tried so far?
    Well, I tried removing the TimePosition changing code, and it works perfectly without that… and unfortunately that’s how I found out about the problem.
    And yes, I did search around the internet, but found no answer.
    I thought about trying to use the KeyframeSequenceProvider service, but for now I prefer to stick to the easier way, just in case there will be a solution to the problem.

Is there really a solution to this that doesn’t require me to remove the TimePosition changing script?
Is it a bug within Roblox’s engine?
Maybe the real bugs are the friends we made along the way?

Thanks for reading :slight_smile:

1 Like

You shouldn’t need to change the time position according to the framerate. The animation system already does this internally.

1 Like

60 FPS: https://gyazo.com/c4ae695f91d0dd0c5717e5252233f6c7
6 FPS: https://gyazo.com/c001932a599645b322cad808aa22a3c8

Interesting. I don’t think this should affect you since physics is also throttled and players would walk slower at 6 FPS.

1 Like

Well, the thing is that I plan to use hits and cooldowns using the markers, and using basic task.wait() functions is not really gonna cut it for me.

1 Like