https://randompoison.github.io/posts/unity-async/
Monday, May 31, 2021
Thursday, April 15, 2021
Sunday, January 31, 2021
Saturday, January 16, 2021
AI Understanding Pac-Man Ghost Behavior
https://gameinternals.com/understanding-pac-man-ghost-behavior?fbclid=IwAR2AlMX2ofDrYJC8G596xBxAWd8eoK7emtiAOeyb5v0lI5Nx0T3_emImaMc
Thursday, January 14, 2021
Explain about Common terminology used throughout the official Spine runtimes.
http://esotericsoftware.com/spine-runtime-terminology/
Atlas An atlas, also known as a texture atlas, stores named regions of a texture. Spine can perform texture packing to create an atlas, or external tools such as Texture Packer Pro can be used (most runtimes use the “libgdx” atlas format).
Animation An animation stores a list of timelines. Each timeline stores keys, each of which have a time and one or more values. When the animation is applied, the timelines use the keys to manipulate the skeleton, fire events, etc. The animation does not store any state.
AnimationState An animation state is a convenience class that holds the state for applying one or more animations to a skeleton. It has the notion of “tracks” which are indexed starting at zero. The animation for each track is applied in sequence each frame, allowing animations to be applied on top of each other. Each track can have animations queued for later playback. Animation state also handles mixing (crossfading) between animations when the current animation changes.
Attachment An attachment is something that is attached to a bone by being placed on a slot. For example, a texture region or bounding box.
AttachmentLoader An attachment loader is used by SkeletonJson to create attachments. This is a hook to provide your own attachment implementations, eg to do lazy loading. Most commonly an attachment loader is used to customize where the images come from for region attachments.
Bone A bone has a local transform (SRT) which child bones inherit. A bone also has a world transform, which is the combination of all parent bone transforms with the local transform. The world transform uses the same coordinate system the root bone is defined in.
Bounding box attachment An attachment that has a polygon for performing hit detection, physics simulation, etc.
Draw order Draw order is a list of slots on a skeleton. The order of the list is the order each slot’s attachment should be drawn, from back to front.
Mixing Mixing, also known as crossfading, is applying an animation by blending linearly between the current pose and the pose for the animation.
Region attachment An attachment that has a texture region and an offset SRT, which is used to position the region relative to the attachment’s bone.
Slot A slot is a placeholder on a bone. A slot can have either a single attachment or no attachment at all. It also has a color and the time elapsed since its attachment was changed.
Skeleton A skeleton holds the state of a skeleton. This includes the current pose, bones, slots, draw order, etc.
SkeletonBounds A skeleton bounds is a convenience class for performing hit detection for a skeleton using the currently attached bounding box attachments.
SkeletonData The skeleton data contains the skeleton information (bind pose bones, slots, draw order, attachments, skins, etc) and animations but does not hold any state. Multiple skeletons can share the same skeleton data.
SkeletonJson The skeleton JSON loads a SkeletonData from JSON.
SkeletonRenderer The skeleton renderer iterates over the slots in the draw order for a skeleton and knows how to render various attachments.
Skin A skin is a map where the key is a slot and name and the value is an attachment. A skin is a level of indirection which allows specific attachments to be found using a slot and a non-specific name. For example, a skin might have a key of [slot:head,name:head] with a value of [attachment:redHead]. Another skin might have [attachment:greenHead] for the same key. The non-specific name is used in animations, enabling animations that change attachments to be reused with skeletons that have different attachments.
SRT Scale, rotation, and translation. Also known as the “transform”.
Transform The scale, rotation, and translation.
Tuesday, January 12, 2021
Orbit around game object
public Transform target;
void Update()
{
Vector3 relativePos = target.position - transform.position;
Quaternion rotation = Quaternion.LookRotation(relativePos);
Quaternion current = transform.localRotation;
transform.localRotation = Quaternion.Slerp(current, rotation, Time.deltaTime);
transform.Translate(0, 0, 3 * Time.deltaTime);
}
First the givens.
relativePos is the vector direction from to target. LookRotation is a function that derives a Quaternion from a vector you'd like your object to face towards. Slerp Spherically interpolates rotation between two rotations meaning it rotates from a given rotation to another smoothly.
Now to the explanation.
It revolves around the target because of the transform.Translate without it your object will just rotate to face the target (because of the LookRotation) on its own axis with no movement. In the tranform.Translate the third parameter (3 * Time.deltaTime) means move the object forward along its z axis 3 units/second therefore it revoles because it's constantly trying to move 3 units/second on the z axis but the Slerp keeps pulling it in making it rotate towards the target so tranform.Translate moves it and Slerp keeps rotating it back to target which results in orbiting.
And you can't just use transform.RotateAround() because
- You won't be able to configure which way your object faces it'll just revolve around a target. You can use it in combination with
transform.LookAt()but that'll result in some jittery effects while on the code aboveSlerpSpherically interpolates rotation which basically means smoother rotation and less jittery. - You won't be able to specify rotation radius with
transform.Translate
The object runs away because in tranform.Translate the third parameter (3 * Time.deltaTime) means move the object forward along its z axis 3 units/second while -3 means move it backward therefore it runs away But if you look closer it's still facing the target. Instead of moving back on the Z axis it moves back along the direction facing the target because of the LookRotation and Slerp functions.
I hope this explained it well if you have any more questions/need more clafication just reply and I'll get back to you.
Pokemon Unity with NPC behavior, Sound Handler
https://github.com/PokemonUnity/PokemonUnity/blob/Beta_Feature_NetworkPlay/Pokemon%20Unity/Assets/Scripts/Alpha/NPCHandler.cs