A-Frame Animation-mixer start animation at a perticular time frame - animation

How can I start an animation from the middle of it (from nth time/frame) in a-frame animation mixer

Soon the animation mixer will have a startFrame attribute which will determine the start time in miliseconds.
There is an easy way to implement it though. The component is based on the THREE.AnimationMixer which is available as a animation-mixer property:
// element refers to an entity with the animation mixer; make sure it's loaded
let mixerComponent = element.components["animation-mixer"]
let mixer = mixerComponent.mixer;
The mixer has a setTime(time) function which will set the animation start at the given time (in seconds):
// will set the start time at 1s
mixer.setTime(1);
If the animation is looped, be sure to do so on each loop:
this.el.addEventListener("animation-loop", e => mixer.setTime(1));
You can see it working here (source)

Related

How should I do this animation or how should I aproach this dilemma?

So, I have a cube and I want to make a game where the cube jumps from a pylon to another and now I am at the point where I want to make the pylon fall if the cube stays on it more than a given amount of time.
I don't want to use physics or rigid body, I am using just transform.position and Raycast to click on the next pylon I want the cube to jump, I want to use animations, so if the cub stays more than a given amount of time on the current pylon, that pylon will fall taking the cube with it.
The problem is that I don't know what to do, where to begin; regarding animations in unity I only know how to do Animation Clips.
I would learn to do other things but I actually have no ideea how to approach this problem, what technique should I use to get the desired outcome, and how?
First you need to detect if the cube is on the pylon.
If it is, then you need to start a timer.
If the timer reaches 0 then the pylon falls.
You can use OnCollisionEnter to Detect if the cube has collided with (landed on) the pylon:
void OnCollisionEnter(Collision col)
{
// Check if it is the cube that has collided.
if (col.gameObject.name == "Player") // Make sure to assign the Player Tag to the cube
{
// Start countdown timer.
}
}
You could start a countdown timer using a coroutine.
You will need to add using System.Collections; at the top of your class.
Call your coroutine using StartCoroutine(MyCoroutine());
IEnumerator MyCoroutine()
{
// Wait for 3 seconds.
yield return new WaitForSeconds(3f);
// Make the pylon fall now.
}
This code will cause the game to wait for 3 seconds before doing something. How you make the pylon fall is up to you, you could use a RigidBody and set isKinematic from true to false as an example, but since you have said you don't want to use physics, you could translate the pylon downwards using Transform.position.
This should get you started.

Unity3d Updating position with animation simultaneously

I have an animation for humanoid models to simulate climbing. I have been looking for a way to stimulate this animation when the model comes next to the window. I used the triggers to determine where the model is and it worked. However, when I execute the animation, the position of the model is not being updated according to the animation. I am using offmesh links and nav mesh agent and I disable nav mesh agent when the model triggers. How can I use the animation and provide the update simultaneously?
Animation Properties
Thanks in advance.
I don't think the animation should take care of the movement. You should control that somewhere else. You could make the animation climb from y = 0 to 5 but then it won't work if your ladder is at y = 3.
You'd better have a method that is called from the animation using AnimationEvent so that when you trigger the animation, it also triggers a movement of the object upwards/downwards regardless of the current position of the object. It would simply use Translate and disabled input until the animation ends.

Is it possible to play skin animation in reverse? [Three.js]

How would I go about playing an animation backwards?
I've tried giving the animation handler negative delta but that just stops it. Subtracting the delta from this.currentTime of the animation doesn't work either.
Any ideas?
Since Three.js r69 it's possible to play animations in reverse order by setting animation.timeScale = -1 though only when animation.loop = true.
See Reverse animation, feature request #5062 for more updates.
I am using r126
Set action.loop = THREE.LoopPingPong will play the clip with the choosen number of action.repetitions, alternately playing forward and backward. (doc)

How to stop animation on the start position / frame zero

I tried to stop the animation objects with a button, I want to when it stops, the object is located at the starting position.
For example I have a cube with animated moving position. when the stop button is pressed, the cube back to its original position.
When no animations are playing, Unity does not change the object's position at all - so stopping it will not reset the position for you. It will just not move it any more.
If you want to return the object to the configuration it was in before you started playing your animation, you have to do it yourself. Your options are:
Make the start position be set by an animation as well. That way you can just play that animation after the other one has finished.
Make the animation you're playing return the object to its start position at the end - i.e. have the last frame of the animation be back at the object's start position.
Write code that captures and restores the object's position, by saving the values of transform.position/transform.rotation and then setting them again when the animation has finished.

Core Animation... cyclic animations?

To phrase my question as simply as possible, is there a way to create a core animation sequence to repeat over and over until a stop?
Specifically, I'm making a custom class that I want to have a -start and -stop method that will cause it to pulsate. Writing the animation code for the pulse is not the problem, rather, how to make it repetitive?
Thanks in advance for any answers!
According to the documentation, you do it by creating an animation with an extremely large repeatCount (code excerpted from the documentation I linked to):
// create the animation that will handle the pulsing.
CABasicAnimation* pulseAnimation = [CABasicAnimation animation];
// over a one second duration, and run an infinite
// number of times
pulseAnimation.duration = 1.0;
pulseAnimation.repeatCount = HUGE_VALF;
// we want it to fade on, and fade off, so it needs to
// automatically autoreverse.. this causes the intensity
// input to go from 0 to 1 to 0
pulseAnimation.autoreverses = YES;
edit: The OP asked how to stop the animation. From the next paragraph in the documentation:
You start an explicit animation by
sending a addAnimation:forKey: message
to the target layer, passing the
animation and an identifier as
parameters. Once added to the target
layer the explicit animation will run
until the animation completes, or it
is removed from the layer. The
identifier used to add an animation to
a layer is also used to stop it by
invoking removeAnimationForKey:. You
can stop all animations for a layer by
sending the layer a
removeAllAnimations message.

Resources