<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mayank Koli</title>
    <description>The latest articles on DEV Community by Mayank Koli (@mayank_kna).</description>
    <link>https://dev.to/mayank_kna</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1281324%2F8cef50f6-8b24-476e-9d66-76ab7d740f12.png</url>
      <title>DEV Community: Mayank Koli</title>
      <link>https://dev.to/mayank_kna</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mayank_kna"/>
    <language>en</language>
    <item>
      <title>Here’s how to use matrices for movement in Unity.</title>
      <dc:creator>Mayank Koli</dc:creator>
      <pubDate>Thu, 15 Feb 2024 04:36:11 +0000</pubDate>
      <link>https://dev.to/mayank_kna/heres-how-to-use-matrices-for-movement-in-unity-5256</link>
      <guid>https://dev.to/mayank_kna/heres-how-to-use-matrices-for-movement-in-unity-5256</guid>
      <description>&lt;p&gt;Unity lets user create a 4x4 matrix which can be used to create a translation, rotation and a scale matrix.&lt;/p&gt;

&lt;p&gt;Multiplying all this you’ll get yourself a transformation matrix.&lt;br&gt;
`// Translation matrix&lt;br&gt;
        Matrix4x4 translationMatrix = Matrix4x4.Translate(new Vector3(2f, 0f, 0f));&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // Rotation matrix (45 degrees around the Y-axis)
    Matrix4x4 rotationMatrix = Matrix4x4.Rotate(Quaternion.Euler(0f, 0f, 0f));

    // Scaling matrix
    Matrix4x4 scalingMatrix = Matrix4x4.Scale(new Vector3(1f, 1f, 1f));

    // Combine the transformation matrices
    Matrix4x4 transformationMatrix = translationMatrix * rotationMatrix * scalingMatrix;`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Here I showed you how to create transformation matrix. Now lets do some operations on it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;transform.position = transformationMatrix.MultiplyPoint(transform.position);
transform.rotation = rotationMatrix.rotation * transform.rotation;
transform.localScale = transformationMatrix.MultiplyVector(new Vector3( 1, 2, 3));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To test this put all this code in a script and stick it to a cube.&lt;/p&gt;

&lt;p&gt;Also unity only lets you create a 4x4 matrix but here’s how you can create a 3x3 matrix.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Matrix3x3{
  public float[,] matrix;
  public Matrix3x3(Matrix4x4 matrix4x4){
    matrix = new float[3,3];
    for(int i=0;i&amp;lt;3;i++){
      for(int j=0;j&amp;lt;3;j++){
        matrix[i,j] = matrix4x4[i,j];
}}}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Why Observer Pattern Sucks</title>
      <dc:creator>Mayank Koli</dc:creator>
      <pubDate>Thu, 15 Feb 2024 04:34:22 +0000</pubDate>
      <link>https://dev.to/mayank_kna/why-observer-pattern-sucks-24dn</link>
      <guid>https://dev.to/mayank_kna/why-observer-pattern-sucks-24dn</guid>
      <description>&lt;p&gt;While making games one of the most commonly used design pattern we see developers use is Observer pattern. Which on one hand is truly great when you look at it. I mean imagine instead of having your player communicate every single event with other objects in scene like health manager, sound manager you can have them individually subscribe to player and observe it. This way all your other components will be disconnected from each other and even if lets say one component stops functioning properly other will work just fine as long as player is working just fine.&lt;/p&gt;

&lt;p&gt;So where's the problem. Well when you’re working on a game with a single player its good to work with observer pattern. But lets say you are making a app which contains cluster of mini games then you'll have to separately write the observer pattern code for them all. Which will in-turn increase the number of scripts. So that's where you got to make the decision if you want to let the number of files increase just to use observer pattern.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
