x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Swapping between three AI companions, and how to spawn without losing previous information (health, exp, etc)

I am currently working a project that is focused on catching, battling, and raising monsters. The player will be able to equip up to three monsters, but can only use 1 at a time. I am having a hard time setting up a blue print that allows the player to spawn and swap between the 3 equipped monsters. I have been through tutorials, and this is what I came up with: alt text

This was placed in the level BP and allows me to spawn and actor while destroying the others. The problem with this set up is that after destroying for example companion 1 when i go to spawn companion 1 again after swapping companions it spawns as a new actor in game. How would i set this BP up to be able to spawn the companion actor again instead of losing all my health, exp, etc information? Think of something like pokemon, but instead of interchanging through 6 I only have three. Any help would be most appreciated.

Product Version: UE 4.15
Tags:
more ▼

asked Aug 16 '17 at 04:43 PM in Blueprint Scripting

avatar image

UpRoar Studios
1 1 2 2

avatar image UpRoar Studios Aug 18 '17 at 06:42 PM

Anyone out there that can help? Im racking my brain right now....

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

If you plan on spawning the actor again, why destroy it? It'd be much easier to either hide or just not render it. Personally, I'd just set up an area under the map or way off to one side and move the actor there until it was needed again. Then you wouldn't have any delays and no messy code to deal with.

During begin play for your character spawn the actors in a hidden area and as you need then move them into the arean. Being only three actors the memory footprint should be fairly small also.

more ▼

answered Aug 18 '17 at 06:59 PM

avatar image

cmarston74
296 6 7 10

avatar image UpRoar Studios Aug 19 '17 at 04:01 AM

so how would i set this up to hide instead of destroy? I have tried actor hidden in game but not sure how it really works...also thank you for your response, would you mind directing me with this set up?

avatar image cmarston74 Aug 19 '17 at 11:44 PM

If I was in your place, I'd make a small room below the map with the same number of markers in it as companions between both players. I'd spawn the companions for both players in the room when the map loaded or play began., and then move the first companion into the playable map where you need it. As the players select a different companion, I'd move the current companion to the hidden room and move the new companion to the playable map.

avatar image UpRoar Studios Aug 20 '17 at 04:26 PM

I understand but our project will have around 100+ usable comapnions. I want to create a system where I can switch them out within the 3 comapnion slots. Would this change the method stated above?

avatar image cmarston74 Aug 20 '17 at 04:48 PM

Not at all. Within your player character, you probably have an array or some method for storing which companions the player is taking into battle or is using at that time. When you start your match, your read your character's desired companions and create whatever companions that want to use in the hidden area. And move the current active companion to the playable area from the hidden area.

avatar image UpRoar Studios Aug 20 '17 at 05:48 PM

How would I call them between the hidden area and then place them back to the hidden area?

avatar image cmarston74 Aug 20 '17 at 06:35 PM

SetActorLocation to place them in the playable area and a second one to return them there.

One thing I might point out is that you might want to use seperate rooms for each team. Otherwise the two teams of companions might decide to get into a fight inside the hidden room since they are AI controlled.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

If you don't want to lose previous information ("health, exp, etc"), you're gonna have to store that information as variables (which you're gonna have to do anyway, if you want to save to a save file and continue where you left off).

So, one Float variable for HP, one for XP, MP, and so on. Then, when you switch to a different "monster", it each has its own HP, MP, preferably displayed on the user interface.

You don't need a "Branch" node at the front (unless you want to check first if one of your 3 monsters died or something before spawning).

And yeah, you can use a "Toggle Visibility" node instead of spawn/destroy, just like you would toggle a light source. There are several tutorials on Youtube on how to turn on/off a light, and it's the exact same thing for meshes, same result as if you would uncheck the "Visible" checkbox in the actor's details.

Constantly spawning/destroying a mesh back and forth is more stressful on the resources than just toggling the visibility of an already spawned mesh.

more ▼

answered Aug 20 '17 at 06:13 PM

avatar image

Andrei Despinoiu
270 4 9 12

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question