[英]Correct way to call animation through and IF statement (A-Frame animation mixer)?
I am currently working with the animation mixer in A-Frame and am attempting to make a condition occur when a specific animation is playing (eg Animation 'B' out of A, B, C).我目前正在使用 A-Frame 中的 animation 混音器,并试图在播放特定 animation 时出现条件(例如,A、B、C 中的 Animation 'B')。
I'm unfamiliar with Javascript but I've made several attempts:我不熟悉 Javascript 但我做了几次尝试:
if(character.getAttribute == character.getAttribute("animation-mixer", {clip: "B"}){
// Insert action here
}
if(character == character.setAttribute("animation-mixer", {clip: "B"})){
// Insert action here
};
if(character.getAttribute("animation-mixer") == {clip: "B"}){
// Insert action here
};
To retrieve component data You should just use getAttribute(componentName) :要检索组件数据您应该只使用getAttribute(componentName) :
// grabbing the component data object
character.getAttribute("animation-mixer")
// same + accessing the clip property
character.getAttribute("animation-mixer").clip
// checking if the property equals "B"
if (character.getAttribute("animation-mixer").clip === "B") {
console.log("Its B!")
}
setAttribute() will change the animation: setAttribute()将改变 animation:
setAttribute("animation-mixer", "clip", "A")
// or character.setAttribute("animation-mixer", {clip: "B"})
character.getAttribute("animation-mixer").clip // A
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.