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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How can i switch between child pawn classes?

So.. the thing starts when i am trying to cast a blueprint child pawn of my main default pawn class and then possessing it and destroying the default pawn. This ticks a neverending list of errors constantly. Besides it doesn't assign the hud to the new child pawn nor will assign its references in level the blueprint, despite the child pawn its working perfectly when its dragged to the level and its set auto possesed by "Player 0" I want to be able to switch between 3 pawns wich are all child of the same parent pawn. I am sorry for my english

Product Version: UE 4.17
more ▼

asked Jun 28 '18 at 08:40 AM in Blueprint Scripting

avatar image

1 2 4

avatar image Nebula Games Inc Jun 28 '18 at 01:11 PM

Post screenshots of how you are doing this.

avatar image GodzillaZuck Jun 29 '18 at 12:33 AM

I cannot upload imges, they get stucked at 0%, either image or attachment wont work. But it's a really simlpe setup, a call of input using the "{" key to "spawn actor from class" returning my child pawn (wich i want to use to replace my main actual parent pawn, using its references) and outputs to a possess node conected to the return value of this last one and my player controller reference. The possessing works just fine, but as for the references (like hud or transforms) it won't do anything, since my parent pawn is still in the level and its updating the hud with its velocity (its a vehicle). And if i call a "destroy" or "un possess" for the parent this will start ticking errors constantly. As i said before, if i drag the child pawn to the level and set "auto possess player" as "player 0" it will work perfectly fine. Parent pawn references will work for this child pawn, but i want to do this in runtime

avatar image ThompsonN13 Jun 28 '18 at 01:33 PM

the references should never work if your changing to a different actor, unless you are resetting them when you posses the new actor. you can avoid some of this by using things like get player character which provides a reference to the character currently possessed. as for the errors i would guess those are a result of the reference problem. the script is probably trying to get information from the first character that you destroyed, but since its destroyed its having errors that it cant fint the needed info. the error your probably getting reads something like "found none trying to access". course this is all just speculation based on what youve written.

avatar image GodzillaZuck Jun 29 '18 at 01:08 AM

i dont think i can use get player character since this will not reference anything from the parent pawn class,its a vehicle so i think its the same for "get player pawn". I know i am doing all wrong when i destroy the parent pawn in the level, All i need is to replace the parent pawn with the child pawn on runtime,mantaining its references that's what i don't know how to do.

avatar image ThompsonN13 Jun 29 '18 at 01:58 AM

you really need to show us your script so we can see what your attempting to do. from what your saying all your really trying to do is spawn in a new vehicle and have its velocity shown on a widget right (or at least to start with). ok so to do this i would use a get player pawn then get velocity and vector length etc as shown in picture 1 for the binding. you may need to cast if your trying to get a variable or something that is specific but as long as its a variable common to the parent then you can just cast to the parent and have the object in as the get player pawn node. i believe this is part of polymorphism, basically the get player pawn gets a reference to the particular pawn the player is possesing without worrying about class, then you can use a cast to define what class it is only to the extent you need (define it to its parent level). doing a cast is basically like asking is the object like the class im casting (comparing) to. so if you have a ford mustang and you cast it to car then it will be true since the mustang inherits the traits from its parent, ie 4 wheels, basic shape, etc.

the first picture shows how i would create the binding, and the second picture shows how i was testing this. i also just added a third picture to show how you could use a cast to accomplish this as well.

alt text

alt text

alt text

capture.png (100.6 kB)
capture1.png (224.8 kB)
capture2.png (86.8 kB)
avatar image GodzillaZuck Jun 30 '18 at 05:29 AM

hey, first of all thanks for keep trying to help. I think my problem it's not the child pawn classes but the respawn thing. The problem starts when i destroy the pawn.. if i call a "spawn actor from class" for the same parent pawn i just destroyed it wont change the problem that it's: 1- update receive draw hud for the new vehicle i just spawn, and: 2- get its transforms (i have a system that keeps adding transforms of the parent pawn to an array and then it uses for set world transform based on set physics linear and angular velocity). so after i respawn none of this either HUD or transforms will work.

1st image is from Parent pawn class: HOLLO 2nd image is from player controller 3rd image is the errors i get after I destroy the pawn. All errors refer to the Vehicle reference in the vehicleHUD, wich is canvas hud, not widget.

captura1.png (209.2 kB)
captura3.png (193.3 kB)
captura4.png (364.0 kB)
avatar image ThompsonN13 Jun 30 '18 at 12:47 PM

the screenshots are all well and good but post one of where the errors are, the hud event graph. all the errors are due to the car being destroyed and the hud trying to read values from it. this tells me the reference isnt being updated in the hud correctly, so thats where we need to start.

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

1 answer: sort voted first

I don't really see the problem :d the next conections are similar to the seen in the second image, all is canvas image and text positioning, some uses calls like rpm string or speed string wich are from vehicle class

captura1.png (416.1 kB)
captura2.png (421.0 kB)
more ▼

answered Jun 30 '18 at 09:05 PM

avatar image

1 2 4

avatar image ThompsonN13 Jul 01 '18 at 03:27 AM

the issue is your setting the reference to a variable then using the variable later down the line. This wouldnt be an issue if you werent destroying the pawn, but as you are that means you will need to either not use the variable or you need an event that re-sets the value when you posses a new pawn. THe second option is easy enough, just create a cistom event and plug it into the same place as the begin play. Then after you posses the new pawn just call the event. All you need is a reference to your hud

avatar image GodzillaZuck Jul 01 '18 at 07:26 AM

Thats a really good idea in fact.. i will give it a try and come back later.. or sooner if this resolves the problem. Thanks again :)

avatar image GodzillaZuck Jul 01 '18 at 08:15 AM

So i don't know how to set your answer as "answer". Anyway.. your are a savior. You were right, calling the new beginplay after posses did the job. I think i wouldn't figured out by myself. The only problem i still have is a warning of set world transform (i think), even if the flag teleport was already checked. Thank you so much, i can finally resume the car selection thing i was trying to do. Thank you, and sorry for my english again d:

captura1.png (176.2 kB)
captura2.png (221.5 kB)
captura3.png (137.3 kB)
captura4.png (7.5 kB)
avatar image GodzillaZuck Jul 01 '18 at 08:49 AM

One more thing. In the level blueprint i created a custom event called Beginplay2 and called it on player controller executing a console command "ce beginplay2" and with that i got my level blueprint references back :-)

(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