playMaker

Author Topic: Get Animation Time  (Read 1603 times)

SkobbejakGames

  • Playmaker Newbie
  • *
  • Posts: 36
    • View Profile
Get Animation Time
« on: May 08, 2014, 02:41:30 AM »
Hi, I am trying to find a "Get" version of the Set Animation Time action already present in playmaker, I thought it would be included already or requested on the forums already, but I cant seem to find anything.

It would realy help us in spawning projectiles for our first person controller at the right time and of the animation (without needing to rely on wait which can be a bit inaccurate or untrsutworthy when it comes to stuff needing to happen at an exact frame, especially if the game runs a bit slow on someone elses machine).

Please any help on the matter would be greatly appreciated and pretty sure there are a few other people on the forums that can find a use for the action as well.

Thanks in advance for any and all help.

EDIT: Also checked Get Property (dragging the animation component into the Get Property) but it just gives me access to the name of the animation clip and a few bool and speed values, but nothing on the current time of the playing animation).
« Last Edit: May 08, 2014, 02:49:47 AM by SkobbejakGames »

terri

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
    • terrivellmann.tumblr.com
Re: Get Animation Time
« Reply #1 on: May 26, 2015, 09:41:38 AM »
looking for this too, ever figure it out?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13526
  • Official Playmaker Support
    • View Profile
Re: Get Animation Time
« Reply #2 on: June 23, 2015, 05:26:20 AM »
Hi,

 instead I would do the following:

 Create an event on the Animation, and have a component acting as a proxy to send a PlayMaker event in turn.

http://docs.unity3d.com/Manual/animeditor-AnimationEvents.html

If you have trouble doing the script, this is one example below:

Code: [Select]
using UnityEngine;
using System.Collections;
using HutongGames.PlayMaker;

public class MyAnimationEvent : MonoBehaviour {

public void AnimationEventTrigger (float theValue) {
Debug.Log ("AnimationEventTrigger is called with a value of " + theValue);

Fsm.EventData.FloatData = theValue;
PlayMakerFSM.BroadcastEvent("ANIMATION TRIGGER EVENT");
}
}

Let me know how it goes.

 Bye,

 Jean

terri

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
    • terrivellmann.tumblr.com
Re: Get Animation Time
« Reply #3 on: June 24, 2015, 07:53:44 AM »
This might work for SkobbejakGames but in my case there are 2 issues:
- The animation is done in Blender, so not sure if AnimationEvents are possible
- I'm mostly looking at transitioning between a walk animation and a run animation that are the same length. The problem is that sometimes depending on where the transition happens, the character will do a weird foot shuffle because the animation transitioned between the steps and doesn't sync up. If I had the time the animation was at before the transition I could play the new one starting at that time and it should work well.

It's a minor thing but Get Animation Time would still be useful in cases!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13526
  • Official Playmaker Support
    • View Profile
Re: Get Animation Time
« Reply #4 on: June 25, 2015, 04:31:02 AM »
Hi,

 Well, the thing is I don't know if there is such api for Unity to do so, if you want a working script doing this, let me know, and I'll have a base to create a custom actions.

else, you should make Animator graph out of your anims and then use the state infos to know when it transits or else. Would it be ok to make a animator graph in your case?

Bye,

 Jean

terri

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
    • terrivellmann.tumblr.com
Re: Get Animation Time
« Reply #5 on: June 25, 2015, 06:04:42 AM »
Oh, that changes things then, not as simple as it seemed.
I'll look into Animator graphs or another solution for it, thanks!