For dynamically batched objects the `unity_ObjectToWorld` shader variable is always set to default?

I’m using the standard render pipeline and the unity_ObjectToWorld variable for some calculations in my shader. After I enabled dynamic batching these calculations got broken. It seems that unity_ObjectToWorld is set to default when the objects are being batched. Is it by design? I didn’t find anything in the documentation.

What size category are weapons if brought to life with the “Animate Objects” Spell?

A wizard at my table wants to use weapons (greatswords) for his Animate Objects spell. Do i take the weapons base damage and match it with the table of Animate Objects (2D6 making them Medium), or are there any rules i may have missed pertaining to the object-size of weapons?

Any clarification, or your own interpretation (if its up to DM’s) would be most welcome.

EDIT: After all your great informative input, I’m going with the following:

  • Weapons weighing 1 lb. or less as Tiny (daggers, darts and ammunition)
  • Heavy Weapons as Medium (glaive, greataxe, greatsword, halbert, maul, pike and h-crossbow)
  • All other Weapons as Small (unless indicated otherwise, oversized for example)

Ability system in Unity: Scriptable objects and collections of generic types

I’ve decided to implement an ability system for my game and set the following requirements:

  • Abilities must be MonoBehaviors, that-is, components of Player/NPC gameobjects
  • Abilities must be able to be added/removed at runtime. Instead of all entites having all abilities on their gameobjects that are disabled/enabled, I’d like to dynamically add/remove abilities using AddComponent/Destroy(component)

Given these I’ve implemented the following:

  • Settings classes which inherit from a base AbilitySettings class which is a ScriptableObject. These contain configurable ability settings as well as an enum called AbilityIdentifier which identifies the ability (for example a jump ability would have the identifier AbilityIdentifier.JUMP)

  • IAbility non-generic interface containing a few common ability methods (such as TriggerAbility and CanTrigger)

  • AbstractAbility<T> class which implements IAbility and T is a type that extends AbilitySettings. It implements some of the IAbility methods and defines others as abstract. Actual abilities extend this class.

  • AbilityManager is a MonoBehavior which contains an array of all possible settings for that entity (added through unity editor) and internally contains a dictionary of <AbilityIdentifier, IAbility>. All of the entities abilities are added/removed using the AbilityManager

It looks something like this:

public class AbilityManager : MonoBehavior {     [SerializeField] private AbstractAbilitySettings[] allAbilitiesSettings = { };          private readonly Dictionary<AbilityIdentifier, IAbility> abilities = new Dictionary<AbilityIdentifier, IAbility>();      // Add/remove ability methods } 

For example, a jump ability pickup gameobject is set somewhere in the world as a trigger. When the player moves over the pick-up object and OnTriggerEnter is executed. The script on the pick-up object gets the AbilityManager and calls AddAbility(AbilityIdentifier.JUMP)

This sounds good but It’s far from perfect. First of all, I couldn’t figure out an elegant way of creating/removing a component when given the settings class so I’ve added the creation/destruction code to the settings class itself. That-is I’ve added the following abstract methods to AbilitySettings

public abstract IAbility InstantiateAbility(GameObject gameObject);  public abstract void RemoveAbility(GameObject gameObject); 

which are then implemented in each of the concrete settings classes like this:

public override IAbility InstantiateAbility(GameObject gameObject) {     JumpAbility ability = gameObject.AddComponent<JumpAbility>();     ability.Settings = this;     return ability; }  public override void RemoveAbility(GameObject gameObject) {     JumpAbility ability = gameObject.GetComponent<JumpAbility>();     Destroy(ability); } 

And these methods are called in the AbilityManager like this

public void AddAbility(AbilityIdentifier identifier) {     AbilitySettings abilitySettings = Array.Find(allAbilitiesSettings, s => s.Identifier == identifier);      abilitySettings.InstantiateAbility(gameObject); } 

The implementation of InstantiateAbility and RemoveAbility is the same for every single ability, the only difference being the ability type. This is a big smell for me. I can’t make AbilitySettings generic and generify the two methods as these settings are in an array.

My questions are:

  • Adding methods such as InstantiateAbility and RemoveAbility to a scriptable object seems like a code smell to me. Take into account that I’m using the AbilityIdentifier to specify to the manager which ability I want to create. I have thought of perhaps creating an AbilityFactory<T> but since it’s a generic class it can’t be a part of an array/list so I’m facing the same problem I did with the settings. Is there a different way I could handle this without having the code in the scriptable object?

  • Having the implementation of these two methods InstantiateAbility and RemoveAbility be the same for every implementation with the only difference being the type is also a big code smell. Is there any way I can generify this but at the same time avoid problems with the inability of having an array or list of those generic classes?

Blender->Unity Import Animation Failing by Overlapping Mesh Objects

I’m new to both Unity and Blender. I created this penguin 3d model, rigged it up and animated it in Blender and all looked good.

When I imported it into Unity, I noticed that this idle animation did not appear to be working correctly. As the body moves, the body mesh overlaps the belly mesh and covers a portion of it.

enter image description here

This is not the case when viewing the animation from blender 2.9.

enter image description here

The belly uses a shrinkwrap modifier with the body as a target.

Is this a problem with Unity import, or how I modeled this penguin in Blender? Can anyone see what I have done wrong here? Any help is much appreciated!

Do Animated Objects make Opportunity Attacks?

Do the objects animated by the Animate Objects spell make opportunity attacks?

While I believe animated objects are certainly capable of opportunity attacks, the wording “If you command an object to attack, it can make a single melee attack against a creature within 5 feet of it” makes me wonder whether additional opportunity attacks are also implicit with this command.

How to make a game object from several game objects in Unity?

Dear Stackoveflow fourm I have programmed a great music game. Unfortunately there is a problem. In my game there are so many objects that my smartphone can’t load the game properly. I have nowhere to find out how to make an object out of many objects. If someone knows how to do it I would be very happy!

My Script:

   using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;  public class line : MonoBehaviour {          //Please attach me to the line, then set  dline,tail,mcamera,road,decorates,dieeff.     //You can add more to make this better!     public GameObject dline, tail, mcamera, road, decorates, dieeff;      private GameObject tempgo, tempdia, tempcr;      public bool direction, alive, start, load, roadmaker;      public float cameraspeed, temprm;      public Vector3 offset, tempcrgo;      private GameObject[] dia, cr;      List<GameObject> go = new List<GameObject>();      void Start()     {         start = false;         load = true;         alive = true;         //find diamonds and crowns         dia = GameObject.FindGameObjectsWithTag("dia");         cr = GameObject.FindGameObjectsWithTag("crown");         //     }      void Update()     {         if (load == true)         {             //save the initial distance between camera and line             offset = mcamera.transform.position - dline.transform.position;             cameraspeed = 0.03f;             load = false;             //         }         //restart         if (Input.GetKeyDown(KeyCode.R) == true)         {             SceneManager.LoadScene("main");         }         //         if (start == false && alive == true)         {//start game             if (Input.GetMouseButtonDown(0) == true || Input.GetKeyDown(KeyCode.Space) == true)             {                 start = true;                 dline.GetComponent<AudioSource>().enabled = true;             }          }//          if (start == true)         {//turn             if (Input.GetMouseButtonDown(0) == true || Input.GetKeyDown(KeyCode.Space) == true)             {                 if (direction == true)                 {                     direction = false;                 }                 else                 {                     direction = true;                 }             }         }//          //build road/wall more efficiently         if (roadmaker)         {             temprm += 1;             //why there is temprm?to reduce the ammount of roads             //why build one when click?to ensure there is road/wall when line turns(or it will look weird)             if (temprm % 6 == 1 || Input.GetMouseButtonDown(0) == true || Input.GetKeyDown(KeyCode.Space) == true)             {                 GameObject.Instantiate(road, dline.transform.position + new Vector3(3, 0, -3), dline.transform.rotation);                 GameObject.Instantiate(road, dline.transform.position + new Vector3(-3, 0, 3), dline.transform.rotation);             }// // //         }         else         {//when you play ...I dont put the part in Update but if(roadmaker) because these actions will create new gameobject and interfere the copying of road             GameObject.Instantiate(tail, dline.transform.position, dline.transform.rotation);             if (Input.GetMouseButtonDown(0) == true || Input.GetKeyDown(KeyCode.Space) == true)             {                 if (direction == true)                 {                     go.Add(GameObject.Instantiate(decorates, dline.transform.position + new Vector3(8, -9, -5), dline.transform.rotation));                 }                 else                 {                     go.Add(GameObject.Instantiate(decorates, dline.transform.position + new Vector3(-5, -9, 8), dline.transform.rotation));                 }             }         }//     }      void FixedUpdate()     {//smooth camera         mcamera.transform.position = Vector3.Lerp(mcamera.transform.position, offset + dline.transform.position, cameraspeed);         //         //some 'animations' .I didnt use animation component because I dont know how it works in Unity :(         foreach (GameObject tempgo in go)         {             tempgo.transform.position += new Vector3(0, 0.2f, 0);         }          foreach (GameObject tempdia in dia)         {             tempdia.transform.localEulerAngles += new Vector3(0, 2, 0);             if (Mathf.Abs(dline.transform.position.x - tempdia.transform.position.x) < 1 && Mathf.Abs(dline.transform.position.z - tempdia.transform.position.z) < 1 && tempdia.transform.localScale.z > 0)             {                 tempdia.transform.localScale -= new Vector3(0.3f, 0.3f, 0.3f);             }         }         foreach (GameObject tempcr in cr)         {             tempcr.transform.localEulerAngles += new Vector3(0, 2, 0);             if (Mathf.Abs(dline.transform.position.x - tempcr.transform.position.x) < 2 && Mathf.Abs(dline.transform.position.z - tempcr.transform.position.z) < 2 && tempcr.transform.localScale.z > 0)             {                 tempcr.transform.localScale -= new Vector3(0.26f, 0.26f, 0.26f);                 tempcrgo = tempcr.transform.position;             }             if (tempcr.transform.localScale.z <= 0)             {                 tempcrgo += new Vector3(Random.Range(-2f, 2f), Random.Range(-1f, 2f), Random.Range(-2f, 2f));                 tempcr.GetComponent<Light>().enabled = true;                 tempcr.transform.position = Vector3.Lerp(tempcr.transform.position, tempcrgo, 0.02f);              }         }         //         if (start == true && alive == true)         {//how the line move             if (direction == true)             {                 dline.transform.position += new Vector3(0.3f, 0, 0);             }             else             {                 dline.transform.position += new Vector3(0, 0, 0.3f);             }         }//     }      void OnCollisionEnter(Collision x)     {//when die...         if (x.collider.tag == "wall")         {             alive = false;             mcamera.GetComponent<AudioSource>().enabled = true;             dieeff.SetActive(true);         }//           //when complete the level...         if (x.collider.tag == "Finish")         {             offset = offset + offset + offset + offset;             cameraspeed = 0.01f;         }//     } } 


Game Scene

Video Link:

Can objects created by Performance of Creation be used as expensive material components?

Tasha’s Cauldron of Everything introduces the College of Creation which gets the class feature Performance of Creation:

As an action, you can channel the magic of the Song of Creation to create one nonmagical item of your choice in an unoccupied space within 10 feet of you. The item must appear on a surface or in a liquid that can support it. The gp value of the item can’t be more than 20 times your bard level, and the item must be Medium or smaller.

…this isn’t a huge deal since there is a gold limit, so the cost of what you could reach is fairly small, but later on the College grants:

Creative Crescendo


You are no longer limited by gp value when creating items with Performance of Creation.

Could you create expensive nonmagical objects such as a diamond for resurrection magic, or the 500 gp statue for imprisonment? Would it work when casting these spells?

How do spells that destroy objects interact with structures

From this answer and DMG 246 quote:

For the purpose of these rules, an object is a discrete, inanimate item like a window, door, sword, book, table, chair, or stone, not a building or a vehicle that is composed of many other objects.

implying structures are considered a collection of objects.

Now, certain spells like Shatter, Delayed Blast Fireball, and Meteor Swarm specifically say that they also damage objects and not just creatures. From the description of meteor swarm:

A creature takes 20d6 fire damage and 20d6 bludgeoning damage on a failed save… The spell damages objects in the area and ignites flammable objects that aren’t being worn or carried.

As a frame of reference, each wall of Instant Fortress has 100 HP, and a 6-inch thick panel of the spell Wall of Stone has 180 HP, all of which can be destroyed with a couple casts of aforementioned spells. Does this mean any wizard with these spells would be able to level any city or even a castle within a span of two or three days? This seems awfully fast. Are there any rules I missed regarding destroying structures from the rules?

How does Wall of Force interact with objects?

Wall of Force discusses what happens when it goes through a creature’s space:

If the wall cuts through a creature’s space when it appears, the creature is pushed to one side of the wall (your choice which side).

…and I assume similar logic can be applied to small/medium sized objects such as chairs that can be moved.

But what about objects that are not a creature, or a single creature, and aren’t particularly mobile?

For example:

a) An enemy is hanging from a rope. Mage casts a horizontal Wall of Force that "cuts" through the rope.

b) A Chain Devil has grappled the fighter from 10′ away with its Chain attack that has 10′ reach. Mage casts Wall of Force between them as part of a hemisphere, hoping to cut the chain and trap the devil.

If the object was a stone wall, I think most would agree that the stone wall stops the Wall of Force as the panels wouldn’t be contiguous or the sphere wouldn’t be able to expand in a direct line from its point of origin.

Does something as thing as a rope or chain have a similar effect?

Could the area of a Wall of Force be greatly reduced just by having streamers hanging from the ceiling, or standing in a forest with a bunch of tall trees?