KeyframeMarker

Afficher les obsolètes

*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.

Un marqueur de KEYFRAME est une instance destinée à représenter un événement qui sera finalement déclenché lorsqu'un Keyframe sera touché.

Utiliser un marqueur de clé

Les marqueurs de cadre de clé doivent toujours être parentés à un cadre de clé via le paramètre parent directement ou en utilisant la fonction Keyframe:AddMarker() du cadre de clé. Les marqueurs de cadre de clé peuvent également être supprimés directement ou en utilisant la fonction Keyframe:RemoveMarker() du cadre de clé, et pollués pour vérifier les marqueurs qui sont attachés à un

Lorsqu'une animation est activée pour un Keyframe, il y aura un événement déclenché pour chaque Keyframe Marker qui est associé au Keyframe. Ces événements sont identifiables par le nom du Keyframe Marker. Vous pouvez récupérer et écouter ces événements en utilisant la fonction AnimationTrack.GetKeyframeMarkerReached. Optionnellement, vous pouvez configurer la propriété Class

Il hérite la propriété Keyframe.Name de Instance et se comporte identiquement. Les noms sont utilisés pour l'identification et n'ont pas besoin d'être uniques. Lorsque plusieurs marqueurs KeyFrame avec le même nom sont attachés à un marqueur KeyFrame, les événements tels que ceux renvoyés par AnimationTrack:GetMarkerReachedSignal() se décl

Voir aussi :

  • Keyframe , contient le Poses appliqué aux articulations dans un Model à un moment donné dans une animations
  • AnimationTrack, contrôle la lecture d'une animation sur un Humanoid ou AnimationController
  • Animation , contient une référence aux données d'animation nécessaires pour jouer des animations personnalisées sur les personnages ou d'autres modèles en utilisant le système d'animation Roblox

Échantillons de code

This example demonstrates the Keyframe:AddMarker() and Keyframe:GetMarkers() functions. After adding two markers, marker1 and marker2 to the keyframe, this example gets and prints the names of the added markers.

Get Keyframe Markers Attached to a Keyframe

local keyframe = Instance.new("Keyframe")
keyframe.Parent = workspace
local marker1 = Instance.new("KeyframeMarker")
marker1.Name = "FootStep"
marker1.Value = 100
local marker2 = Instance.new("KeyframeMarker")
marker2.Name = "Wave"
marker2.Value = 100
keyframe:AddMarker(marker1) --marker.Parent = keyframe
keyframe:AddMarker(marker2) --marker.Parent = keyframe
local markers = keyframe:GetMarkers()
for _, marker in pairs(markers) do
print(marker.Name)
end

This LocalScript code waits for the local player's Humanoid object to load, then it creates a new Animation instance with the proper Animation.AnimationId. The animation is then loaded onto the humanoid, creating an AnimationTrack, and the track is played with AnimationTrack:Play(). Following that, the AnimationTrack:GetMarkerReachedSignal() function detects when the "KickEnd" marker is hit.

Listening to Keyframe Markers

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.Character:Wait()
local humanoid = character:WaitForChild("Humanoid")
-- Create new "Animation" instance
local kickAnimation = Instance.new("Animation")
-- Set its "AnimationId" to the corresponding animation asset ID
kickAnimation.AnimationId = "rbxassetid://2515090838"
-- Load animation onto the humanoid
local kickAnimationTrack = humanoid:LoadAnimation(kickAnimation)
-- Play animation track
kickAnimationTrack:Play()
-- If a named event was defined for the animation, connect it to "GetMarkerReachedSignal()"
kickAnimationTrack:GetMarkerReachedSignal("KickEnd"):Connect(function(paramString)
print(paramString)
end)

Propriétés

Value

Lecture parallèle

Une valeur qui est spécifiée pour un KeyframeMarker. Lorsque le signal créé à partir de AnimationTrack:GetMarkerReachedSignal() est activé, cette valeur sera transmise à la fonction connectée.

Voir aussi :

Échantillons de code

This example demonstrates the Keyframe:AddMarker() and Keyframe:GetMarkers() functions. After adding two markers, marker1 and marker2 to the keyframe, this example gets and prints the names of the added markers.

Get Keyframe Markers Attached to a Keyframe

local keyframe = Instance.new("Keyframe")
keyframe.Parent = workspace
local marker1 = Instance.new("KeyframeMarker")
marker1.Name = "FootStep"
marker1.Value = 100
local marker2 = Instance.new("KeyframeMarker")
marker2.Name = "Wave"
marker2.Value = 100
keyframe:AddMarker(marker1) --marker.Parent = keyframe
keyframe:AddMarker(marker2) --marker.Parent = keyframe
local markers = keyframe:GetMarkers()
for _, marker in pairs(markers) do
print(marker.Name)
end

This example demonstrates the Keyframe:AddMarker() and Keyframe:RemoveMarker() functions. Note these are functionally equivalent to parenting and un-parenting the markers.

Add Marker/Remove Marker

local keyframe = Instance.new("Keyframe")
keyframe.Parent = workspace
local marker = Instance.new("KeyframeMarker")
marker.Name = "FootStep"
marker.Value = 100
keyframe:AddMarker(marker) --marker.Parent = keyframe
task.wait(2)
keyframe:RemoveMarker(marker) --marker.Parent = nil

Méthodes

Évènements