Unity Runtimes API docs

Discuss issues pertaining to the various game/web runtimes of Creature here.
Post Reply
pg_interactive
Posts: 16
Joined: Thu Feb 22, 2018 2:42 pm

Unity Runtimes API docs

Post by pg_interactive » Sun Jul 22, 2018 9:34 pm

Hi, i have two questions:

1) Is there any API documetation, additional to
https://www.kestrelmoon.com/creaturedoc ... times.html
(im looking for a standarized API reference)?

2) Looking to achieve specific functionality - let's say there's an animation, 100 frames, and i'd like to tell it to play normally, and once it reaches frame 80, id like to loop from frame 60 to frame 80 (in code). Is there a way to do this using current API? I tried to call

Code: Select all

creature_manager.setRunTime (float time)
creature_manager.RunAtTime (float time)
but that only changes the run_time of the current animation, not the visuals (no looping). What would be the best way to achieve this functionality (think GoToAndPlay (int frame_number) or GoToAndPlay (float time)) ?

chong
Posts: 835
Joined: Thu Feb 19, 2015 2:21 am

Re: Unity Runtimes API docs

Post by chong » Sun Jul 22, 2018 11:14 pm

Hello,

1) That is the official API reference, new functions are reflected on that docs page.

2) If you want to safely execute the character, I suggest:

Code: Select all

creature_manager.setRunTime(time);
creature_manager.Update(0); // Updates with a delta time of 0, effectively posing your character at the current time
One reason I am guessing you are not seeing the character gettig updated is because even though the internal character
data has been updated, you did not trigger an update to the rendering mesh.

Take a look at:
https://github.com/kestrelm/Creature_Un ... enderer.cs

Code: Select all

And in particular LateUpdate():

	public virtual void LateUpdate () 
	{
		if (creature_manager != null) {
			doSwapMesh ();

			if (creature_asset.GetIsDirty() || vertices == null)
			{
				CreateRenderingData ();
				creature_asset.SetIsDirty(false);
			}

			UpdateTime();
			UpdateRenderingData (); // Updates the Rendering data to sync up with the character

			meshFilter.sharedMesh = active_mesh;
		}
	}
After the time has been set, make sure thae UpdateRenderingData() is called. If you are setting your
custom time, you probably want to modify UpdateTime() to take into account your custom time. That way
the UpdateRenderingData() syncs up with your desired time.

For custom looping behaviour you specified, I recommend you write custom logic by modifying UpdateTime() and
incrementing/looping the time counter yourself, then calling setRunTime() and Update(0).

Post Reply