Looks like the AI package is in the middle of big changes

So I didn’t see AI in my Window options. I added the AI package from the package manager. The new Navigation window does NOT have Bake or Object on it. I had to open the “Navigation (Obsolete)” window which warns about it being deprecated. Something to really look out for (2022.2.0b4.2768).

Thanks for the heads up. I’ll have to look into this. It’s possible that they’ve finally (after seven years of beta versions) implemented the NavMesh Components. These components finally let you have multiple navmeshes that can be rebaked at runtime, and reside on a GameObject rather than as a separate static system. This system would let you have different sized agents.

1 Like

Oh cool… Yeah I figured it was something long in the works… like how long the new Input system took. I really hope they go update the RPG courses with the new Input system. I will eventually update it all myself once I finish them all if needed, though.

In fact, I started this course to take a break from the RPG course… So it threw me how current this one was and completely different style than Rick and Sam have. I think, sadly, I am putting this course on the backburner for a bit until a better 2022 release is out. I have errors all over the place that don’t seem to affect anything, but irritate me nonetheless. And this NavMesh stuff is odd.

I’m also terrified for when the time comes to finally tie it all together. This combat/control system with everything else from the RPG courses(plus splicing in some other things). Hopefully a full release of 2022 is available and everything will play nicely. Otherwise I am really loving 2021.3.5f1 while actually using VStudio 2022 (they REALLY upped the auto-complete game in 2022).

(Edit: If I can be bothered, I’m really considering starting this course over in 2021… Scripts will be fine, just having to make new prefabs and hook everything up. I know the guys really want to be forward looking for longevity, but 2022 just feels not ready)

Rather than updating with the new input system, I’m planning a transition guide, although several students who have been through this course have successfully transitioned to the new input system.

It should run fine in the later versions of 2021. I know Nathan started us out in a 2022 beta, but as a rule of thumb, I recommend always using a version that ends in .f1. I’ve had excellent success in the 2022.1 .f1 versions. Betas are notoriously buggy (hence being betas). In fact, the whole point of a Beta is to let us do all the hard work of finding the bugs so they don’t have to!

1 Like

Awesome on the transition guide! That makes me confident it should be just as easy as setting up the action events like we have in this course and add the listeners where needed.

And oh yeah. I used to beta test in the golden era of MMOs… Literally almost every one released from 2001-2010 or so. Back before just buying early access or donating to a kickstarter got you beta. You had to apply and wine and dine the community reps :joy: But I took it very seriously and helped squash some bugs.

I guess I thought maybe something special from 2022 was going to show up in this course and it only occurred to me a few lectures in that they are just trying to futureproof as much as possible. But I’ll definitely keep reporting any differences I see. Keep up the good work, Brian!

To generate a navmesh using a later version of Unity 2022, you will need to use the package manager to import the AI Navigation Package. Now to generate a navmesh, you will want to place a NavMeshSurface component on a either a new GameObject or on an existing one(Such as the terrain GameObject). Make sure that you flag the terrain and rocks as Static(And most likely the houses). Now you can bake a navmesh using the NavMeshSufrace component you had placed in the scene. The Windows>AI>Navigation tab will let you adjust the values for the different types of agents(IE: Humanoid or another custom one) Such as: Radius, height, Step height, and the slope. It will also let you set up “areas” to make certain “areas” in the game cost more to move. IE: water vs ground. Hope this helps. Cheers

UPDATE: Apparently the new NavMeshSurface tool doesn’t take terrain painted trees into consideration, I believe that when a navmesh is baked, it takes any static meshes and compares their height, slope, etc with the parameters of the navmeshsurface to determine if it is walkable or not. So what you could do is attach the following script to the terrain gameobject, then click the context menu extract option. Then bake the NavMeshSurface, then hide all the children created by the script under the terrain gameobject.

// Borrowed and refactored to work correctly from:
// https://forum.unity.com/threads/navmeshsurface-and-terrain-trees.1295496/#post-8504006

using System.Linq;
using UnityEngine;
 
[RequireComponent(typeof(Terrain))]
public class ExtractTreeCollidersFromTerrain : MonoBehaviour
{
    [ContextMenu("Extract")]
    public void Extract()
    {
        Terrain terrain = GetComponent<Terrain>();
        Transform[] transforms = terrain.GetComponentsInChildren<Transform>();
 
        //Skip the first, since its the Terrain Collider
        for (int i = 1; i < transforms.Length; i++)
        {
            //Delete all previously created colliders first
            DestroyImmediate(transforms[i].gameObject);
        }

        for (int i = 0; i < terrain.terrainData.treePrototypes.Length; i++)
        {
            TreePrototype tree = terrain.terrainData.treePrototypes[i];

            //Get all instances matching the prefab index
            TreeInstance[] instances = terrain.terrainData.treeInstances.Where(x => x.prototypeIndex == i).ToArray();

            for (int j = 0; j < instances.Length; j++)
            {
                //Un-normalize positions so they're in world-space
                instances[j].position = Vector3.Scale(instances[j].position, terrain.terrainData.size);
                instances[j].position += terrain.GetPosition();

                //Fetch the collider from the prefab object parent
                CapsuleCollider prefabCollider = tree.prefab.GetComponent<CapsuleCollider>();
                if(!prefabCollider) continue;

                GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Capsule);
                obj.name = tree.prefab.name + j;

                if (terrain.preserveTreePrototypeLayers) obj.layer = tree.prefab.layer;
                else obj.layer = terrain.gameObject.layer;

                obj.transform.localScale = Vector3.one * prefabCollider.radius;
                obj.transform.position = instances[j].position;
                obj.transform.parent = terrain.transform;
                obj.isStatic = true;
            }
        }
    }
}

Hope this helps someone. Cheers

Privacy & Terms