I'm developing a grid battle RPG and I need help with the following:
I'm trying to make a Game Object (Building) spawn when a Combatant enters the cell. This Game Object (Building) has the color of the Combatant's faction that entered the cell.
When a Combatant from another faction enters the same cell, I would like the previous Game Object to be destroyed and a Game Object (Building) with the colors (Faction) of the new Combatant to be spawned.
I managed to spawn the Game Objecs, but I am not able to destroy them.
Another problem I noticed, and which seems to be similar to the first one, is that if the Player faction Combatant re-enters the cell, the Prefab/ Game Object (Building) is spawned again.
Ideally, there should not be a new Spawn, as the Game Object (Building) is already in the scene.
The later event spawning a new prefab has no access to the prefab that was spawned before.
You can solve that by remembering that prefab, e.g. as Selected Data: - Select Game Object node using Object selected data on the cell and storing the spawned prefab - Destroy Object node to destroy the game object stored in the cell's Object selected data
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
I've added the suggested nodes, but it's still like I can't store the prefabs. I feel like I must be missing something simple here. Here's how the event went:
Check Faction = Player Success = Spawn Prefab(01)
Select Game Object: Selected Key Value Type = Value Value = MarketPlayer Origin Date = Local Change Type = Add
Game Object Settings: Object = Selected Data Value Type = Game Variable Value = MarketPlayer Variable Origin = Global Origin Date = Local
Failed = Select Game Object: Selected Key Value Type = Value Value = MarketPlayer Origin Date = Local Change Type = Add
Game Object Settings: Object = Selected Data Value Type = Game Variable Value = MarketPlayer Variable Origin = Global Origin Date = Local
Destroy Object Object = Selected Data Value Type = Game Variable Value = MarketPlayer Variable Origin = Global Origin Date = Local Destroy after time = 3
Check faction = Enemy Success = Spawn Prefab(02)
Select Game Object: Selected Key Value Type = Value Value = MarketEnemy Origin Date = Local Change Type = Add
Game Object Settings and Destroy Object follow the same idea... Value = MarketEnemy
In the end, none of the Prefabs are destroyed, continuing to overlap. Can you show me where I'm going wrong and how to fix it please?
Hard to say with that list of settings, can you post a screenshot of your event? Make sure to destroy the previous prefab before storing the new prefab into selected data.
Post edited by gamingislove on
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Hm, where did you send it? Didn't get an email yet.
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Ah, the gmail address isn't monitored, so only send your emails to contact@orkframework.com. The gmail is only needed to get access to your google drive stuff.
Checked the images, yeah - that's not working :) Use a setup like this:
1) Destroy Object node: - object: Selected Data - value type (selected key): Value (since you want to define the key directly) - value: whatever you want, but use the same for all other selected data access (for both player and enemy factions, since only one prefab should be there at a time) - data origin: Object (stored on the cell) - object (selected key): probably Target if it's a cell targeting ability, otherwise wherever you stored the cell
2) do your prefab spawning
3) Select Game Object node: The Selected Key should have the same setup as in #1, i.e.: - value type (selected key): Value - value: same as in #1 - data origin: Object - object (selected key): Target (or wherever your cell is stored) - change type: Set For the game object settings: - object: Prefab - prefab: your spawned prefab
That's all.
First, it'll destroy the stored prefab, next it spawns the new one and stores it on the cell. Just keep in mind to enable using Object Variables in your cell types, best set to Local Variables. Selected data uses the same access as that.
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
You can solve that by remembering that prefab, e.g. as Selected Data:
- Select Game Object node using Object selected data on the cell and storing the spawned prefab
- Destroy Object node to destroy the game object stored in the cell's Object selected data
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
First of all, thanks for your help as always.
I've added the suggested nodes, but it's still like I can't store the prefabs. I feel like I must be missing something simple here. Here's how the event went:
Check Faction = Player
Success = Spawn Prefab(01)
Select Game Object:
Selected Key
Value Type = Value
Value = MarketPlayer
Origin Date = Local
Change Type = Add
Game Object Settings:
Object = Selected Data
Value Type = Game Variable
Value = MarketPlayer
Variable Origin = Global
Origin Date = Local
Failed = Select Game Object:
Selected Key
Value Type = Value
Value = MarketPlayer
Origin Date = Local
Change Type = Add
Game Object Settings:
Object = Selected Data
Value Type = Game Variable
Value = MarketPlayer
Variable Origin = Global
Origin Date = Local
Destroy Object
Object = Selected Data
Value Type = Game Variable
Value = MarketPlayer
Variable Origin = Global
Origin Date = Local
Destroy after time = 3
Check faction = Enemy
Success = Spawn Prefab(02)
Select Game Object:
Selected Key
Value Type = Value
Value = MarketEnemy
Origin Date = Local
Change Type = Add
Game Object Settings and Destroy Object follow the same idea...
Value = MarketEnemy
In the end, none of the Prefabs are destroyed, continuing to overlap. Can you show me where I'm going wrong and how to fix it please?
Thanks in advance
Make sure to destroy the previous prefab before storing the new prefab into selected data.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Thanks for the feedback. I just sent you an email with all the screenshots. If you need anything else, just let me know and I'll be ready.
Thanks a lot!
Didn't get an email yet.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
The subject is the same as this thread.
Prints - Destroy prefabs/ Game Objects Battle grid ORK 2
Thanks!
The gmail is only needed to get access to your google drive stuff.
Checked the images, yeah - that's not working :)
Use a setup like this:
1) Destroy Object node:
- object: Selected Data
- value type (selected key): Value (since you want to define the key directly)
- value: whatever you want, but use the same for all other selected data access (for both player and enemy factions, since only one prefab should be there at a time)
- data origin: Object (stored on the cell)
- object (selected key): probably Target if it's a cell targeting ability, otherwise wherever you stored the cell
2) do your prefab spawning
3) Select Game Object node:
The Selected Key should have the same setup as in #1, i.e.:
- value type (selected key): Value
- value: same as in #1
- data origin: Object
- object (selected key): Target (or wherever your cell is stored)
- change type: Set
For the game object settings:
- object: Prefab
- prefab: your spawned prefab
That's all.
First, it'll destroy the stored prefab, next it spawns the new one and stores it on the cell.
Just keep in mind to enable using Object Variables in your cell types, best set to Local Variables. Selected data uses the same access as that.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Thank you one more time!
Thanks! Your help has been essential at key moments in the development of my game.
I tried to follow what I understood and the prefab is still not being destroyed.
I hadn't commented before because I didn't know if it would make a difference, sorry about that, but the event is being triggered by a skill.
I sent an email with screenshots of the changed events. I must be missing something simple here...
Thanks in advance,
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!