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"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

possess already existed pawn?

I have a character A which is the main character of my game. i have used below method to spawn another character and possess it. its works no problem till then.

but now i want to possess my previous character A (main character) without re-spawning it? i dont know how to get reference of my main character into my 2nd character blueprint??

i just want to change characters which are inside level now i dont want to cycle characters but specifically select the one i want to select. and possess it!

alt text

Product Version: Not Selected
possess.jpg (200.6 kB)
more ▼

asked Mar 18 '15 at 01:27 PM in Blueprint Scripting

avatar image

143 30 33 94

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

You could save a reference to every character you want to use inside of your character and just use that one to change it.

If you just want it inside of your character you can create a variable of the type of your first pawn (in your second one or a reference of your second pawn in your first one), make it editable and also enable "Expose on spawn". When you spawn it, it will create an additional pin where you can provide your other pawn to or in the case that you just spawn it inside of your character save it right after that in a variable.

I hope this was understandable^^

Cheers :)

more ▼

answered Mar 18 '15 at 01:46 PM

avatar image

5.9k 291 86 293

avatar image VeerChidar Mar 18 '15 at 02:43 PM

actually i just understood half of it.. i'm still pretty much a noob.. i can do this in level blueprint easily but not in character.

can you show me a blueprint node setup.. if possible?

avatar image Erasio Mar 18 '15 at 04:15 PM

I'm not near a computer which can run the engine until tomorrow so it'd be more ideal if I could describe it.

Basically in the details of your variables you have a few options. You can create a new one, check "Editable" and "Expose on Spawn". When you spawn a new instance of that class you will have one more pin in which you can plug in a reference to the current character ("Self"). (Just try this part... it'll be easier to understand ;)

Like this that variable will be already set. Not with a default but with the character you spawned it in.

Does this help a bit more?

avatar image VeerChidar Mar 18 '15 at 04:58 PM

By what i understood i created a variable in my 1st character BP.. i have set it to my first character BP and i have checked editable and expose on spawn. i saw in my 2nd character BP there is a new pin in SpawnActor node... but now even after adding the return value from this node to possess "in pawn" its not switching back rather creating a new character in my game ... do i have to use this new pin somehow.. if yes then where to join it??

avatar image Erasio Mar 18 '15 at 05:01 PM

Well you will have to check if it already exists. Since you already have variables you can just check them with the "IsValid" node. If it's valid just swap to that one. Otherwise create a new one.

You should also right after you spawned the character save a reference to it in the character you spawned it from so when you're back at that one you can then do the same with that variable.

avatar image VeerChidar Mar 18 '15 at 05:13 PM

this is the 2nd character graph...is this good so far.. i mean i'm not getting it why i need to use transformation when i just want to switch back to my first character which is already in the game..

btw, thanks for giving time to help me..

alt text

untitled-2.jpg (187.3 kB)
avatar image Erasio Mar 18 '15 at 05:29 PM

No you're supposed to provide the variable with the spawn event. Especially for your second character. You spawn it and because you don'T want to spawn the first character a second time you just provide it's variable as reference. You won't need a transform or the spawn node. Just that reference.

avatar image VeerChidar Mar 18 '15 at 05:35 PM

but then what to plug in transform.. otherwise it gives error! and how to get reference from character1st thats the whole problem! i'm in total dark here...

avatar image Erasio Mar 18 '15 at 05:42 PM

Alright you have your first character. That one is spawned by the playerstart in your level and selected in your gamemode.

In there you have a reference to your second character as variable. This should be default be null or none. Simply empty. You check if it is empty and if that is true you spawn a new one. This other actor has a variable with has the "Expose on spawn" pin enabled. In there you can provide your reference from the first character. Just plug "Self" in there. Now in this second character the first is already referenced since you did that when spawning it and you can switch back.

Don't forget to keep the reference to your second character in your first one so the second time you try to switch from it the variable for your second character is filled.

avatar image VeerChidar Mar 19 '15 at 07:08 AM

i just want to switch back to my first character which is already spawned by playstart... what you told me so far is not working at all...

if i need to use transform node in 2nd character its working i'm getting a new character in certain location.. and if you are saying that i need to get the reference of first characters location and plug it into transform node.. then i'm on the same problem how to get the transformation of playstart character's current location?? even somehow i managed that but still spawning new character.

and so far i have no ideas how to use that new pin poping up in the spawn node on the left side of it..

i have also tried creating a variable of my first character in 2nd character and tried to use "get actor transformation" to plug in transform node of spawn but still doesnt work.. spawning more characters instead of switching back to my first one..

avatar image Erasio Mar 19 '15 at 09:00 AM

...yes. Obviously. Because you use the node "Spawn Actor from Class". I just told you like two statements ago you should forget that one together with the transform because since you already have that character spawned and at a location you will not need to set that one new. You just need to provide a reference of your first character to the "Possess" node.

alt text

This is the script you want. If you have that variable filled just possess it. Otherwise you spawn a new one and refer the spawning character as reference. You can use this script in both characters. In fact the smartest thing would be to create a parent class with this function and then just use your characters as children so you only have to write this once. "Switch To Character" is set to "Expose on Spawn". In this case I just spawn exactly the same character a second time.

possess.png (153.8 kB)
avatar image VeerChidar Mar 19 '15 at 09:22 AM

It worked thanks alot.. i was getting confused because i wasnt connecting "self" into that new pin... thanks :)

(comments are locked)
10|2000 characters needed characters left
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