TheGameCreators / GameGuruRepo

The GameGuru Repository For Community Collaboration
http://www.game-guru.com
137 stars 56 forks source link

LUA Command to spawn objects. #4135

Open CharleneMaure opened 1 year ago

DaveTGC2 commented 1 year ago

I think we'll need some more information :). Are you saying there is a duplicate Lua command or are suggesting we should add a command to duplicate an entity?

CharleneMaure commented 1 year ago

suggesting sorry :)

Necrym59 commented 1 year ago

You cant duplicate or clone an active entity yet, that means spawning and spawning is not yet in Max

davetgc commented 1 year ago

Ok, so this is a request for a spawn feature. Got it.

AmenMoses commented 1 year ago

There is already a Lua command to spawn an object but what is meant here is as Necrym59 says creating or cloning objects on the fly.

The problem with creating new objects is how do you specify which objects to create (as by definition they won't be on the map yet!) or where to put them!

With cloning you could have it just so it makes clones of the object the script is attached to, but again how do you specify where to spawn them, obviously if you just pass in a position and orientation to the Lua command that sort of suffices but GG/MAX is for non-coders, how would you meaningfully use this in a game just by the game maker altering some sliders or whatever?

The other problem I can see is that the standalone process populates the files with entities that are on the map, if a script is going to generate entities on the fly how does the standalone know what those entities are in order to include them?

On top of that you have performance issues to deal with, the long load times in part are down to the time taken to create the in game entities, especially things like the physics bodies and then making the nav mesh based upon those entities, that hit will now occur whilst the game is playing if you create them on the fly, if the entities are complex and use polygon physics shape you may fine the game slows to an absolute crawl when creating/cloning.

A few years ago I had a script that used the lunar lander model from the Sc-Fi pack and flew it around. I initially had it as-is with poly collision mode and used CollisionOff/CollisionOn calls around the movement code and the FPS dropped to single figures simply due to the extra processing required to create the physics shape every frame, and that was just a single entity on an empty map!

A lot of thought will need to go into implementing this sort of feature when in most cases there are far easier ways of doing things in a game. (for example having a fixed pool of entities from which to spawn from repeatedly!)

Teabone3 commented 1 year ago

A fair request. I think this is a request to clone objects to spawn into the scene from a single instance of an existing dynamic entity, similar to other engines that per-cache defined entities with a maximum limitation per entity type (typically a value of 200).

We have physical 3D projectiles that pre-cache with user-defined values in the projectiles TXT file. This happens just before test game, and with gunspec update enabled in setup.ini, this is pretty seamless to see changes made to projectile total spawn value, take affect once test game is pressed.

FPS drops also in other engines when using in-game cloning too, though momentarily, as its does its physics settle. With the new renderer and 64-bit I would be curious to know how bad it would be to clone a minimal amount or single additional entity.

Technically if TGC went with the cell/neighboring approach with maps for open world development for GGMax, we would need to re-cache 100s of entities anyways and off load and on load them on the fly which would disable and re-enable their physics.

Least this is my assumptions on the matter with using other engines. Also not sure when DLUA processes, but if defined as a clone-able/spawn-able entity with a toggle-able option for the user (either DLUA or externally in a project setup file), that could maybe be a way to give access to pre-caching? If say 4 entity instances were allowed to be clone-able with a set number of 200 each (or much less).

For now, i just recommend placing down set number of entities in reserve and hiding them (and their collisions) and freeze their script processing to wait till they are "spawned" in. For enemies most (linear) games never actually "destroy" their enemies anyways, they just put them back on the reserve for spawning elsewhere on the map.

Necrym59 commented 1 year ago

An entity cache thats loaded into the map for use from level to level for projectiles, inventory items or crafted itrems or spell projectiles, effects and particles etc would be the answer. I think everything in max is an instance of a loaded object if im not mistaken so cloning should not be an issue i would have thought.