I am trying to play car door open and close animation when we press UI buttons. But its not working here is my script attached to the car entity. Please refer the screen shot below. I have referred this Anim State Graph Blending | Learn PlayCanvas
@Albertos But I dont want to play anything at the Initial moment i want it to be empty. I want to play the animation if and only if we press a button.
And hope my script is correct
Ok so first of all there are two animation one is door closing and another one is door opening. I don’t want to use the initial state because if i put either one of my animation in the initial state it will play(for ex if i put door open animation in initial state the door will be opened in the starting of the scene which is exactly i dont want) and mainly we dont have a idle animation for a car. So renaming will not work in my case i think. You can check the project I shared you will understand what’s going on @Albertos
Below the version with my suggestions applied. The only problem with this is that the doors are closing at start. This is because there is no empty state possible at the moment. Maybe @Elliott can consider looking at the possibilities for this.
AddAnimations.attributes.add('animationAssets', {
type: 'json',
array: true,
title: 'Animation Assets',
schema: [{
name: 'stateName',
title: 'State Name',
type: 'string',
}, {
name: 'asset',
title: 'Aseet',
type: 'asset',
assetType: 'animation'
}]
});
// initialize code called once per entity
AddAnimations.prototype.initialize = function() {
// To mimic the older Animation component, the state name will be the name of the asset
for (var i = 0; i < this.animationAssets.length; ++i) {
var animationAsset = this.animationAssets[i];
this.entity.anim.assignAnimation(animationAsset.stateName, animationAsset.asset.resource);
}
};
is there any way to turn off loop by script of these animations i add?
@Albertos I tried the same what you did in the Forked project but its not working for me. Can you tell me if i did the same what you did in the forked project? refer these screenshots. I don’t know what is wrong here my script is fine btw!