<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.figuramc.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=PencilVoid</id>
	<title>FiguraMC - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.figuramc.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=PencilVoid"/>
	<link rel="alternate" type="text/html" href="https://wiki.figuramc.org/index.php/Special:Contributions/PencilVoid"/>
	<updated>2026-05-29T17:41:22Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.figuramc.org/index.php?title=Tutorial:Blinking&amp;diff=277</id>
		<title>Tutorial:Blinking</title>
		<link rel="alternate" type="text/html" href="https://wiki.figuramc.org/index.php?title=Tutorial:Blinking&amp;diff=277"/>
		<updated>2024-09-27T15:58:18Z</updated>

		<summary type="html">&lt;p&gt;PencilVoid: Phrasing changes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Avatars may blink as a means to convey a character&#039;s personality and suggest liveliness. This can be done by creating a separate model part for the character&#039;s eyes, and scaling them to give the appearance of blinking.&lt;br /&gt;
&lt;br /&gt;
To begin with, define variables containing parameters the script will use: the path to the eye model, their height, and the length of the blinking animation.&lt;br /&gt;
[[File:EyeGroup.png|thumb]]&lt;br /&gt;
&amp;lt;syntaxHighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local eyes = models.model.root.UpperBody.TheHead.Eyes&lt;br /&gt;
local EYE_HEIGHT = 2 --The height of your eyes in blockbench units&lt;br /&gt;
local BLINK_RATE = 4 * 20 -- 4 Seconds&lt;br /&gt;
&amp;lt;/syntaxHighlight&amp;gt;The &amp;lt;code&amp;gt;BLINK_RATE&amp;lt;/code&amp;gt; particle is multiplied by 20 as the script will deal in ticks, and there are 20 ticks in a second.&lt;br /&gt;
&lt;br /&gt;
Next, the logic that determines when to blink will be performed in a &amp;lt;code&amp;gt;TICK&amp;lt;/code&amp;gt; event. 4 new variables will also be needed to store the calculated position and scale for the eyes, alongside a simple timer. These will be initialised outside of the &amp;lt;code&amp;gt;TICK&amp;lt;/code&amp;gt; event.&lt;br /&gt;
&amp;lt;syntaxHighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local oldScale = vec(1, 1, 1)&lt;br /&gt;
local newScale = vec(1, 1, 1)&lt;br /&gt;
local oldPos = vec(0, 0, 0)&lt;br /&gt;
local newPos = vec(0, 0, 0)&lt;br /&gt;
&lt;br /&gt;
local tick = 0&lt;br /&gt;
function events.TICK()&lt;br /&gt;
  -- Sets old pos and scale for later interpolation&lt;br /&gt;
  oldPos = newPos&lt;br /&gt;
  oldScale = newScale&lt;br /&gt;
  tick = tick + 1&lt;br /&gt;
&lt;br /&gt;
  -- If time to blink, set new position and scale to close the eyes, otherwise open them&lt;br /&gt;
  if tick % BLINK_RATE == 0 then&lt;br /&gt;
    newScale = vec(1, 0, 1)&lt;br /&gt;
    newPos = vec(0, EYE_HEIGHT / -2, 0)&lt;br /&gt;
  else&lt;br /&gt;
    newScale = vec(1, 1, 1)&lt;br /&gt;
    newPos = vec(0, 0, 0)&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxHighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to give the blinking a smooth appearance, the rendered position and scale will be calculated and set in a &amp;lt;code&amp;gt;RENDER&amp;lt;/code&amp;gt; event, using the variables initialized earlier.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxHighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function events.RENDER(delta)&lt;br /&gt;
  -- This interpolates the blinking to make for a smooth blink&lt;br /&gt;
  local scale = math.lerp(oldScale, newScale, delta)&lt;br /&gt;
  local pos = math.lerp(oldPos, newPos, delta)&lt;br /&gt;
&lt;br /&gt;
  eyes:setPos(pos):setScale(scale)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxHighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>PencilVoid</name></author>
	</entry>
</feed>