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"

How do I switch character blueprints

I'm prototyping a game where the character can transform into different forms when collecting different powerups.

Each character has different collision and skills and I want to switch the character blueprints rather than just the mesh. How do I approach this???

The first character is the main while the other two are the transformations. We see here that the main character's collision spheres stay the same even after transforming. alt text

This is all in the main character blueprint

OnCollisionOverlap > Cast to Coin (Powerup) > Destroy Coin > Set NewAnim > Set New Mesh > Delay 5s > SetMainAnim > Set Main Mesh alt text

alt text

Thanks in advance!

Product Version: UE 4.14
character_bp.jpg (138.8 kB)
character_bp.jpg (138.8 kB)
code_1.jpg (182.9 kB)
code_2.jpg (177.9 kB)
more ▼

asked Feb 05 '17 at 05:06 AM in Blueprint Scripting

avatar image

28 4 8 10

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

2 answers: sort voted first

Okay so acouple of suggestions, you should perhaps try to use some inheritance to save copying alot of code over all the time.

Instead of each Character and Coin being their own thing you do:

  -  Main Character
  |- Hero
  |- Main Morph
  |-- First Morph
  |-- Second Morph

What this means is all of your sub Characters will inherit from their parent BP, what happens then is MainHero can be defined in the main Morph and any other Morphs you decide to create will work based on existing functionality.

Similarly with Coins:

 - Main Coin
 |- First Coin
 |- Second Coin

With your copy of my code you made a minor error:

alt text

Should be...

alt text

The reason for this is because you need to store your old Hero in the current Morph to switch back to it when the timer is up. The reason you store it there is that the coin gets destroyed so the reference might end up becoming invalid. Since its in an active Actor you dont have to worry about that happening.

Keep up the good work, youre doing really well so far :)

coinright.jpg (95.8 kB)
more ▼

answered Feb 09 '17 at 08:41 AM

avatar image

1k 37 12 38

avatar image juztinmikael Feb 09 '17 at 10:33 AM

Thank you MonsOlympus! Everything works now. I just realized that I was calling a different variable on the IsValid output. I'll study this and I'll try another transformation and see if I can get a 3rd one to work. Thanks very much for your for your time! :D :D

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

You'll need to Possess each new Character so that your Controller gives you input to them.You'll need to spawn a new Character, Possess it then Destroy the old one.


more ▼

answered Feb 05 '17 at 05:14 AM

avatar image

1k 37 12 38

avatar image juztinmikael Feb 05 '17 at 08:30 PM

That worked great! Now my problem is to revert it back to the main character since the bp switching is only for few seconds. I tried a delay node but people said it will never work. Here's my new code

OnCollisionOverlap > Cast to Coin (Powerup) > Destroy Coin > Destroy Main > Spawn New Char > Posses

Is switching back to the Main Character BP still possible?

avatar image MonsOlympus Feb 06 '17 at 01:48 PM

You probably will need to spawn another one unless you save the old Character as a reference in your current Characters BP, like a PrevCharacter variable. This will allow you to reset its position and unhide it instead of constantly spawning a new one each time since this is the main character. You can pass this variable when you spawn the new Character and doesnt need to be destroyed but it will need to be disabled, hidden etc.

The best bet is a Timer that resets the Character back rather than a delay since it'll run ontop of other code rather than delaying any flow that may happen in the mean time.

avatar image juztinmikael Feb 08 '17 at 12:51 PM

Thank you for the tips! I tried the timer but I can't get it to work. I know there's a missing piece somewhere I just don't know what.

These are all in the main character blueprint btw

alt text

alt text

This is custom event "Morphing" alt text

I tried adding a delay (which is redundant) after the timer but it still does nothing. I also connected the chain from beginoverlap directly to the timer, although it kindda worked, the chain skipped the 2-second delay from the timer I'm not sure why. Any thoughts?

set-timer1.jpg (355.5 kB)
set-timer2.jpg (424.5 kB)
set-timer3.jpg (202.8 kB)
avatar image MonsOlympus Feb 08 '17 at 02:28 PM

Okay so instead of yammering on about things I decided to show you an example, lets see if you can work it out from what Ive done here :)

This is using version 4.14.3 so hopefully thats the same as youre running. Basically I just made what I was talking about before so if you have questions just let me know.

crystaldemo.rar (1.5 MB)
avatar image juztinmikael Feb 09 '17 at 08:02 AM

Thanks for all the help :D

I used your assets and they worked fine on a different project, then I copied all your blueprints but the timer still doesn't work in my own project. I've attached my files if you'd like to take a look.

link to my dropbox

avatar image juztinmikael Feb 12 '17 at 09:23 AM

Hi again, I tried doing it with another character and I always get infinite loops everywhere only in the morph2 animation blueprint. I parented the sub characters to my main character as well as the coin like you suggested. I'm not sure what's causing the infinite loops here

link text

thank you :)

hero_run.zip (4.6 MB)
avatar image MonsOlympus Feb 15 '17 at 05:23 PM

You havent provided all the files I need to run that correctly, maybe you could start a new question with some pictures of whats going on then anyone has a chance to jump in and answer.

I did load up your files but there are alot of bad cast nodes so I cant tell whats wrong but I'll do what I can if you provide some more info.

avatar image juztinmikael Feb 16 '17 at 10:10 AM

Hi, I was able to fix the infinite loops, but another set of problems came up after. I created a new question about it.

link text for new question


(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