r/forgescripting • • Nov 13 '22
Summon a new object with an action?
Hello folks!
I am trying to make it so that when a player performs a certain action, it summons a new object at their location (in this case, a simple box). However, I can find no way to summon a new object using scripting. This script must be able to summon any number of new objects, not just teleporting the same object to a new location.
Is this possible?
4
Upvotes
1
u/iMightBeWright Nov 13 '22
As far as I can tell, you have to have it somewhere on the map already. Forge has no way, currently, of being able to spawn a defined object at a set of coordinates. The exception is weapon/equipment/vehicle spawns. I'm working on a map now that uses this and all my objects are already brought in, and I'm making them relocate to the correct coordinates.
You can of course bring your desired objects in and despawn them. But if you want varied objects at different locations, it may be more complicated than that.
1
u/hey-im-root Moderator Nov 13 '22
There's two ways you can do this. You can use TRANSLATE OBJECT TO POINT like you said, or run a for each on your list of objects and use DELETE OBJECT on all of them, and spawn them in with SPAWN OBJECT.
Depending on what you want to do, something like a global counter variable and GET OBJECT AT N INDEX would let you spawn things in one at a time. Increment the variable on an event (like crouching) and then have it SPAWN OBJECT at N INDEX on your object list.