Jump to content

Spawning and Nav Mesh Agents


Oafkad

Recommended Posts

I stress in advance that I'm a bit tired so this particular update is probably going to read like garbage.

  Another productive night. I wanted to accomplish a few things tonight. The first is I wanted to be able to spawn anything. I might not know what those things are yet but I wanted the system for adding new spawners to be convenient. I also didn't want a lot of casting to be involved, so these spawners would at least be dedicated to the object they will be spawning.

  The next challenge was to make sure that these objects pool. We don't want to just be creating and destroying a lot of assets. So the major first step was adding a pooling system to the spawner. Conveniently I've already made an interface for pooling and was able to hook that right in. This meant that we had a spawner for our Kitties now, and that we could spawn them anywhere we wanted.

  But I hit a snag. I would tell them to move to a precise position and rotation but they would not. I would break point and everything looked correct. Yet when I went back into the scene it was all...well...not correct.

  I started mulling over what could have such an impact on position and it hit me. Oh right! The nav mesh agent! Our little cube baby was trying to protect us from moving it somewhere illegal. So it was just flat out ignoring my request. The solution for this was quite simple, I have the nav mesh disabled on spawn and it will be enabled as part of the loading process.

  I suppose next we should go with a complimentary collection of images and a gif. To basically close out the night. Tomorrow we will want to create the artifact for our Moosecat spawner so that other objects can trivially interact with it (and get data back). I'm not as sure that we'll hook up game loading to it for now because I don't actually think that provides us any value at this time. I know it'll work, you know it'll work, and making fake stuff for the sake of making fake stuff is just time wasting.

  Well would you look at that. A bit hard to see I admit but we can see our cube at a 45 degree angle and, quite rudely, it pushes the player out of the way. We can also see the cat being added to the pool. The way our spawners work is they check for a pooled object, if they find one they simply return that object unpooled. Otherwise they'll create a new object and add it to the pool for tracking.

  Generally an object is pooled if it is disabled. Simple and clean without any need to communicate between the pooling array and the pooled objects therein.

  Alright! I'm gonna go rest! Progress is progress.

 

Link to comment
Share on other sites

×
×
  • Create New...