March 5th, 2018

Examples of Progress with Gear Mesh Generator in Unity

The approach for creating a full gear mesh in Unity was to create a single section of a gear with one tooth with the given parameters/dimensions, then replicate this a number of times equal to the total number of gear teeth and rotate each of these instances appropriately to create a single full gear. An extra bit of scripting was added to place small black spheres around the vertices of the first gear segment created, to highlight the locations of the created vertices.

The prior setup was tweaked to account for the control of spaces between the gear teeth. This appears to have made the instances of the meshes concave in some manner though, so the convex mesh colliders do not completely accurately follow the model around the teeth now. Another technique will be looked into to prevent this from happening.

Parameters:
  • Number of Teeth: 10
  • Thickness: 0.1
  • Body Radius: 0.5
  • Tooth Height: 0.1
  • Tooth Width: 0.1
  • Space Between Teeth: 0.15
Parameters:
  • Number of Teeth: 12
  • Thickness: 0.25
  • Body Radius: 0.75
  • Tooth Height: 0.15
  • Tooth Width: 0.15
  • Space Between Teeth: 0.15

Video Demonstrations of Gear Generation Script at Work

Shows Physics of Full Gear Mesh

As can be seen from this video, the full gear mesh acts as one object even though it is made of several individual objects each representing a gear segment. It also shows that it has basic physics function within Unity’s game space.

Shows Changing Parameters to Create Different Gear Shapes

This video shows directly how changing the parameters of the script relates to changes of the resulting gear mesh. Currently, all the work is loaded at the start of the scene. Further work will be done to translate this to something that can be edited real time.

Current Equations for Determining Geometry of the Gear Mesh – Shown for Creating Single Gear Section

Parameter Equations
  • angleForSpaceBetween = Mathf.Asin(spaceBetweenTeeth / (2 * bodyRadius));
  • angleForSpaceBetweenDeg = Mathf.Rad2Deg * angleForSpaceBetween;
  • distanceToCenterOfSpace = bodyRadius * Mathf.Cos(angleForSpaceBetween);
  • angleBetweenSections = 360 / numberOfTeeth;
  • halfAngleBetweenSections = angleBetweenSections * Mathf.PI / 360 – angleForSpaceBetween; // Cuts in half and converts to radians
  • cosineTheta = Mathf.Cos(halfAngleBetweenSections);
  • sineTheta = Mathf.Sin(halfAngleBetweenSections);
  • cosineThetaAlpha = Mathf.Cos(halfAngleBetweenSections + angleForSpaceBetween);
  • sineThetaAlpha = Mathf.Sin(halfAngleBetweenSections + angleForSpaceBetween);
Vertex Equations
  • newVertices[0] = new Vector3(0, 0, 0);
  • newVertices[1] = new Vector3(bodyRadius * sineTheta, bodyRadius * cosineTheta, 0);
  • newVertices[2] = new Vector3(-bodyRadius * sineTheta, bodyRadius * cosineTheta, 0);
  • newVertices[3] = new Vector3(-toothWidth / 2, bodyRadius * cosineTheta + toothHeight, 0);
  • newVertices[4] = new Vector3(toothWidth / 2, bodyRadius * cosineTheta + toothHeight, 0);
  • newVertices[5] = new Vector3(0, 0, thickness);
  • newVertices[6] = new Vector3(bodyRadius * sineTheta, bodyRadius * cosineTheta, thickness);
  • newVertices[7] = new Vector3(-bodyRadius * sineTheta, bodyRadius * cosineTheta, thickness);
  • newVertices[8] = new Vector3(-toothWidth / 2, bodyRadius * cosineTheta + toothHeight, thickness);
  • newVertices[9] = new Vector3(toothWidth / 2, bodyRadius * cosineTheta + toothHeight, thickness);
  • newVertices[10] = new Vector3(distanceToCenterOfSpace * sineThetaAlpha, distanceToCenterOfSpace * cosineThetaAlpha, 0);
  • newVertices[11] = new Vector3(-distanceToCenterOfSpace * sineThetaAlpha, distanceToCenterOfSpace * cosineThetaAlpha, 0);
  • newVertices[12] = new Vector3(distanceToCenterOfSpace * sineThetaAlpha, distanceToCenterOfSpace * cosineThetaAlpha, thickness);
  • newVertices[13] = new Vector3(-distanceToCenterOfSpace * sineThetaAlpha, distanceToCenterOfSpace * cosineThetaAlpha, thickness);
March, 4th 2018

Creating 2D Enemy Movement in Unity that is Able to Avoid Obstacles

How can I make an AI that avoids obstacles WITHOUT using NavMesh?

This link contains oStaiko’s answer to the above question, and describes two standard ways to deal with basic enemy AI movement, especially on a 2D plane. These two ways are: a waypoint setup and a more “vision” focused setup.

Waypoint Setup Pros/Cons
  • Good on static maps where enemy can “know” the entire map
  • Deciding fastest routes can be tricky
Vision Setup Pros/Cons
  • Works better for non-static maps/obstacles
  • More difficult to setup (scripting-wise)
  • Better for open maps, can work poorly in more constricted spaces

Example Script for Setting Up Raycast AI to Move Around Obstacles

Unity 3D – Enemy Obstacle Awareness – AI – Code Sample

This link leads to some sample C# code for setting up a script that gives an object raycast vision to avoid obstacles and refocus on a target.

Mar. 4th, 2018

Research for DIGM 540

Designing for Transformative Play by: Jon Back, Elena Marquez Segura, and Annika Waern

This paper could serve as a very useful base behind my current project for designing editable physical engineering mechanisms within the Unity game engine. I could use this idea along with my toy to look into creating a more open, user defined play area. This paper focuses on play designed in an open way.

Some Important Key Words:
  1. Human-Computer Interaction (HCI)
  2. Human-Centered Computing
  3. Interaction Design
  4. Interaction Design Theory
  5. Explorative Play
  6. Creative Play
  7. Transformative Play
Further Topics to Look Into:
  1. Ludic Design by Gaver et al.
  2. Stenros Thesis on foundational theory of play

Current Progress of Research Paper

Link to Google Doc of Paper Information

March 2nd. 2018

Talks on Game Design

SINFO, March 1st, 2018 – Greg “Ghostcrawler” Street from Riot Games – 20 Things I Learned in Twenty Years of Making Games

Talk on his career path as a game designer, and good ways to advance yourself as a game designer. Same key points are: Make things good enough, not perfect (consider diminishing returns); you will change jobs a lot; games ship when you run out of money; have goals and iterate; making a team is harder than making a game; as a game designer, not smarter than players (all people informed on game); empathy. Emphasize importance of varied types of people on teams producing elements of game (combine programmer, artist, designer, etc.)

Difference between Blizzard and Ensemble companies – Iteration. Ensemble: create something, put it in game, test. This worked but was a bit inefficient. Blizzard: Ideas must go through a lot of thought and people before even being created, which means most things created in game are going to be higher quality, which results in a more efficient process.

    How to get into game industry?

  • You have to stand out
  • You have to prove your passion
  • The best way is to make something

Compromise with feedback, take something from beginning to end, kill your babies, understand diminishing returns. Rather see someone finish things than start a bunch of things. See someone push through with changes and edits to finish something than just giving up (shows endurance, will to push through for end product).

Bennet Foddy – Bend Physics to your Will

Feb. 28th, 2018

Research for DIGM 540

  1. Predictive Physics Simulation in Game Mechanics by: Perttu Hämäläinen, Xiaoxiao Ma, Jari Takatalo, Julian Togelius
  2. Interactive Control For Physically-Based Animation by: Joseph Laszlo, Michiel van de Panne, and Eugene Fiume

Other Interesting Topics Encountered

  1. The lack of research in soft bodies (as opposed to rigid bodies) in the physics engines of games.

    Covered in: Unifying Rigid and Soft Bodies Representation: The Sulfur Physics Engine by DarioMaggiorini, Laura Anna Ripamonti, and Federico Sauro

Feb. 27th, 2018

Scripting Enemies to Check Distance for Ranged Attacks – Unity

Scripting is Fun – Unity 2D Game Basics – Enemy AI – Ranged Attack – Youtube Video

This video shows the basic setup for allowing an enemy in a 2D game to rotate, locate player with raycasting and distance tracking, and fire projectiles in the proper direction.

Unity Manuals – Layers

This is placed here for the use of layer masks to control raycasts. Layer masks allow the user to either ignore specific layers with their raycasts, or specifically target layers. This was searched because I had an issue where raycasts where colliding with the object itself and/or the parent object, both of which have colliders.

Feb, 25th, 2018

DIGM 540 Project – Resources

  1. Basic Mesh Scripting Tool Description for Unity
  2. Creating Basic Billboard Mesh Through Unity Scripting
    Shows how to create a vertex array, set these into triangles, and create a full mesh.

  3. More Help for Procedural Generation of Mesh

This shows that it is possible to create/modify meshes within Unity using scripting.

Project Direction – Create Script in Unity that Will Take User Inputs to Instantiate a Gear Model Based on Said Parameters

This may be possible through the general use of the Mesh class in Unity scripting. Something along the lines of creating a set of vertices for the central body (some smoothness level of cylinder), then creating a gear tooth mesh that can be multiplied and geometrically positioned around the central core body mesh created.

Bump Mapping

Normal Maps from Unity

“Normal Maps and Height Maps are both types of Bump Map. They both contain data for representing apparent detail on the surface of simpler polygonal meshes, but they each store that data in a different way. A height map is a simple black and white texture, where each pixel represents the amount that point on the surface should appear to be raised. The whiter the pixel colour, the higher the area appears to be raised.

A normal map is an RGB texture, where each pixel represents the difference in direction the surface should appear to be facing, relative to its un-modified surface normal. These textures tend to have a bluey-purple tinge, because of the way the vector is stored in the RGB values.”

Displacement Maps

Unity Displacment Maps and Tesselation

Tri Setup to Create Mesh for Gear Segments