Integrating gpt2 into unity

I was wondering if anyone had any pointers in integrating gpt-2 into unity. I’ve got quite a bit of experience with python, but less with unity. What I’m trying to do is use a pretrained gpt2 model in a unity projects to act as an nps brain. If possible I would also like to be able to export it with everything so the user doesn’t have to also go and install libraries.

I’m not quite sure how I would do this, so any help is appreciated

How to make my Unity project deterministic for replays?

I am working on an arcade-style 2D shmup and recently started implementing a replay system that allows players to view their runs of the game.

I use the technique of recording input each FixedUpdate() and rerunning the game as a simulation, reading the saved input each frame and processing it in the core game loop as if it was real-time input from the player.

This requires an extremely deterministic game, and in order to get perfectly synced movement and scoring in the replay, I have had to shift to a paradigm of using exclusively FixedUpdate() and Time.fixedDeltaTime.

I don’t mind this, as I now have 100% reliable replays with no desyncing.

My question concerns whether some of the techniques I used to port my game to the deterministic FixedUpdate paradigm are problematic, or if there are better ways to achieve the same effect.

For example, previously I relied heavily on coroutines yielding using WaitForSeconds(). This method is underpinned by normal Update() loop and so introduced indeterminism into the game leading to desyncs.

To fix it, I still use coroutines, but any time I need to wait, I do it by waiting for n number of calls of FixedUpdate(). For example,

for (int i = 0; i < 60; i ++) {     yield return new WaitForFixedUpdate(); } 

This seems to be working just fine to keep the game deterministic, but I wonder if there’s a more straightforward way, or if there are potential issues this type of technique might cause?

In general, are there any other techniques or pitfalls I need to be aware of to keep my game deterministic enough for perfectly synced replays?

Google’s Play Asset Delivery Build aab File in Unity too large

I want to upload an aab file from my unity project to my play console account, but unfortunately, my file was rejected because it’s size is larger than the 150MB threshold limit for aab on google play store.

Then while looking for a solution, I found out that obb files are now made obsolete and I could use google’s Play Asset Delivery system to upload my file. So then I followed the "not so clear" instructions on how to use the PAD system in Unity, I made an asset bundle that contains all my font asset(because that was what increased my aab from 120MB to 260MB), and added it to the Asset Delivery Settings in Unity and selected "Separate Base APK Asset". Then I built the aab file using PAD(by clicking Google > Build Android App Bundle), and my generated aab went from 260MB to 680MB.

Why did the size increase enormously? Isn’t the point of it to reduce the size on the aab so that it can be accepted by play? Am I missing something or have I done something wrong?

Unity world curve shader graph, how to start curving from a specific distance?

I’ve made simple world curving shader following some online tutorials and cleaning few things up. It’s doing its job, however I have small issue where it curves objects that are very close to a camera. So, I am trying to figure out how to start curving only if objects are certain distance form the camera, lets say 20 units or more?

Below is a sub-graph I use to output a value for a vertex position i.e. curve world shader, this is the one I need to figure out how to modify

enter image description here

How to create random interpolated polygon shapes based Mesh in Unity?

I want to generate random Polygon (or maybe I am not using correct term) shapes as Mesh generated randomly and dynamically from script in runtime as shown in the picture attached. enter image description here

I want to use as Mesh Collider based on those procedurally generated shapes, I am using those shapes as to detect Bounds.Contains a certain gameObject’s position. I also want to assign a transparent material to those shapes, that will only be a color though or a diffuse texture with different opacity.

I have seen some tutorials on how to generate mesh from script, but it only helps me if I know the vertices positions exactly and how to adjust the tangents. I am unable to make them randomly generated. If you can help me correct the technical term used for this kind of shapes will also be useful. Or any work done before similar to this in the form of an Asset available on Unity store, or github repository. Or maybe even basic idea on approach how to research it or do it.

Unity – Spot/point realtime lighting not working

Spot/point realtime lights are not working. No light at all.

  • I have an urp scene with a realtime directional light that works perfectly, intensity, shadows, etc.
  • Spot/point realtime lights dont work.
  • When set to mixed/baked these lights are actually baked.
  • Realtime doesnt do light over static/non-static gameobjects.
  • I baked the scene previously but now I cleared the scene from the lightmaps, although the realtime lights should work over non-baked objects for sure.
  • When only one light in all the scene active still not working (even the directional is off), so I guess is not the limit.
  • All of this is in the editor.
  • Created a different scene in the same project and still not work.
  • Same scene with same materials, gameobjects, etc in a different project work.

It seems like it is something from the project.

enter image description here

enter image description here

enter image description here

How to create a directory template in Unity?

How to create a directory from a template with multiple files in it which are also created from templates?

Right now, I am particularly interested in creating an Assembly directory which uses a user-entered variable ASSEMBLY_NAME, take the project name variable from the settings and would create the following simple file hierarchy:

  • $ {ASSEMBLY_NAME}/
    • $ {PROJECT_NAME}.$ {ASSEMBLY_NAME}.asmdef

where the $ {PROJECT_NAME}.$ {ASSEMBLY_NAME}.asmdef file would contain:

{   "name": "$  {PROJECT_NAME}.$  {ASSEMBLY_NAME}" } 

… but I would also be glad to learn any way to create whatever complex templated hierarchies, like creating a class and a companion test script together at once, create a directory with a "readme" file in it, etc.

I know this is somehow possible, because there is a default Unity UI function which does exactly the same, but for test assemblies only, so it adds extra code in the assembly definition file which I don’t need.

enter image description here

I cannot find anything on this topic apart from answers on how to create/edit a single file templates, e.g.:

  • How do I customise automatically-generated script?
  • https://stackoverflow.com/questions/39461801/unity-add-default-namespace-to-script-template

Unity Procedural Game Optimization

I am currently developing a 3d dungeon crawler which implements a procedural dungeon generation system which works perfectly fine. I am currently trying to optimize the game to the best of my abiltiy. These are some of the this I’ve implemented so far please let me know if you have any other suggestions:

  • Static Batching for all the generated rooms and all the generated decor using StaticBatchingUtility.Combine()
  • Occlusion Culling (though I am not sure if it works correctly because the dungeon is generated at runtime, maybe you have any suggestions on how to correctly implement it)
  • LOD Groups for each room prefab and decor object
  • Custom mesh colliders made in blender that have a low poly count for each object
  • Hard Shadows on all point lights, that are realtime, and currently using defferd lighting on the project settings. And the lights light up as you enter the room.
  • Quality settings are kept as default
  • Currently there is only a fps controller and the dungeon generator so there aren’t any other scripts that might be impacting performance
  • No effects or particle systems in the scene
  • All objects use the same material and is not cloned when the prefab is instantiated.

If you have any other suggentions I would really appreciate it. If you need any more info please don’t hesitate to ask. Thanks

Currently getting around 160 - 180 fps,

This script doesn’t work and I don’t know why. | Unity 2D C#

Here is the army code:

using System.Collections; using System.Collections.Generic; using UnityEngine;  public class Army : MonoBehaviour {     public int ArmySize = 100;      private Vector2 lastClickedPos;     private bool moving = false;     public float speed;      public SpriteRenderer sprite;      private GameObject Village;      private void Start()     {         Village = GameObject.FindGameObjectWithTag("Village");     }      private void Update()     {         if(Input.GetMouseButton(0))         {             sprite.enabled = true;             lastClickedPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);             moving = true;         }          if(moving && (Vector2)transform.position != lastClickedPos)         {             float step = speed * Time.deltaTime;             transform.position = Vector2.MoveTowards(transform.position, lastClickedPos, step);         }         else         {             moving = false;         }          if(ArmySize < 0)         {             ArmySize = 0;         }     }      private void OnTriggerEnter2D(Collider2D other)     {         if(other.gameObject.CompareTag("Village"))         {             Debug.Log("Attack");              if (ArmySize <= Village.GetComponent<Village>().strength)             {                 Debug.Log("Lost");                 ArmySize -= 30 % Village.GetComponent<Village>().strength;             }              if (ArmySize > Village.GetComponent<Village>().strength)             {                 Debug.Log("Won");                 ArmySize += 15% Village.GetComponent<Village>().strength;                 Destroy(other.gameObject);             }         }     } } 

and here is the village code:

using UnityEngine;  public class Village : MonoBehaviour {     public int strength;     private int x;      private void Start()     {         StrengthValue();         strength = x;          Debug.Log(gameObject.name + " ---- " + strength);          transform.localScale = new Vector3(strength / 100, strength / 100, 1);          if(transform.localScale.x < 1 && transform.localScale.y < 1)         {             Debug.Log(gameObject.name +  "Is Destroyed");             Destroy(gameObject);         }     }      private void StrengthValue()     {        x = Random.Range(10, 500);     } } 

the problem is that it sometimes doesn’t destroy the village even though the army size is bigger than the village’s strength. I also got an error but I can’t seem to re-create it. I think it was something about an object reference? But don’t think that that’s 100% right.

Prevent Unity From Loading The Next Scene After Getting to the Final Scene

I’m a beginner in Unity, I wrote a script that will load the next scene whenever monsters in a scene are dead. The script is working fine. Here’s my script.

public void Update() {     if (MonstersAreAllDead())         GoToNextLevel();  }      //Loads The next Level After all the monsters are Confirmed Dead  private void GoToNextLevel() {     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);      }  

However, I only have two scenes in my game and When Unity gets to the final scene, it displays an error since there is not next scene to load to.

Scene with build index: 2 couldn't be loaded because it has not been added to the build settings. To add a scene to the build settings use the menu File->Build Settings... UnityEngine.SceneManagement.SceneManager:LoadScene (int) LevelController:GoToNextLevel () (at Assets/Scripts/LevelController.cs:39) LevelController:Update () (at Assets/Scripts/LevelController.cs:30) 

My question. How do I tell unity that it should stop trying to load the next scene and instead Display a message to the user? The message displayed can be something like "This is the final scene".

Thank you all in advance for your answers.