Announcement

Collapse
No announcement yet.

Level blueprint is fine.. until I reload level then it won't compile

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Level blueprint is fine.. until I reload level then it won't compile

    Well last night I thought I solved one of the big problems in my mission to make my game flexible
    Click image for larger version

Name:	Untitled-1.png
Views:	1
Size:	121.3 KB
ID:	1053922

    I was stoked, over the moon. My Level blueprint has no hard-coded information as to what is going to spawn and it gets it from my gamestate

    This works fine and it compiles.

    Until I load another level in the editor and then go back to it. When I go back it doesn't compile

    So far I have found there are two points that break, but if I connect it in the right order it works, until it loads again.

    So the first problem is that I can spawn my pawn no problem, but when I go to "possess" it, it complains that possession is for pawns, not actors. It seems the spawn actor function is, unsurprsingly, for actors.

    However, if instead of plugging a variable into the Class node of SpawnActor, I just select an example pawn from the list, it works fine, exactly as it's meant to. AND NOW, if I change that node back to using the variable that contains the exact same value, it works. It's as if the actor->pawn problem doesn't exist anymore

    But reload, and the problem is back.

    Is there a way to cast from actor to pawn? I mean, pawn is a sub-class of actor right?

    #2
    I can "hack" it and make it work by using auto possess on my actor. It seems like a bad solution, one that wouldn't be good if one day I wanted to expand to multiplayer.

    It seems like a technical type checking issue where it won't let me take possession of a spawned actor, even though it's a spawned pawn, because it passes my spawned pawn out as an actor


    :UUU

    Comment


      #3
      Pawn IS a subclass of Actor, no doubt about that.. Are you unable to cast to pawn simply because it doesn't show up in the context menu, or because it won't compile?
      DO contact me with questions about Blueprint or other Unreal features! I don't bite! Or charge money! Just press that blue Skype button and fire away.

      Project Culverin - Open Ended First Person Shooter

      Comment


        #4
        Originally posted by Ray Jones 312 View Post
        Pawn IS a subclass of Actor, no doubt about that.. Are you unable to cast to pawn simply because it doesn't show up in the context menu, or because it won't compile?
        It depends on when* I drag between the nodes. Sometimes it compiles and sometimes it doesn't. I can't find an explicit cast, unfortunately, in the context menu.

        If I explicitely choose my pawn in the spawnactor node it works, and then if I use my variable to that it works, BUT if I reload the level it doesn't work

        Comment


          #5
          I am open minded as to whether or not my approach is fundamentally wrong but here is what I want to achieve

          Get type of pawn from gamestate (via a "Get Current Ship" function I made which passes an Actor as an class) (currently testing this with hardcoded value in the gamestate but making array with the ships I want to choose from is the next challenge, not this one)

          Spawn that in the level (preferably at where I place player start, which I pass to my spawning function, this way I can just move the player start if I need to)

          Take possession of it.


          (the reason I want to do it like this is so that when I make a new level I have to copy and paste as little code as possible to make it work with the game, I even made a spawning macro (which works but has the same problem) so from my level blueprint I can call the macro and with only a few nodes spawn my ship

          Click image for larger version

Name:	Untitled-1.png
Views:	1
Size:	53.2 KB
ID:	1053997

          Here you can see the problem that crops up. Even with the extended version this is the problem. Although sometimes it's NOT a problem and it compiles :/



          I know it should work in theory because if I choose "auto possess by player 0" on the class I am spawning then the whole thing works fine. The problem is in the taking possession after it has spawned.
          Surely taking possession of a spawned pawn is a common thing?

          Comment


            #6
            I SOLVED IT!

            While mucking around trying other things, I found that if you added a SpawnController node, it automatically offers a "convert from actor to pawn" function, so I copy and pasted that into my macro and so now it outputs the actor as a pawn!

            I can only assume this conversion is meant to be offered automatically but this has been a whole evening of frustration trying to make this work!


            Now onto my next challenge, working out how to make an array of my ships. I could do it manually I guess or use a "add all actors with interface" and make sure all my ships have a general interface". Ideally I'd use those tags you can add to blueprints

            Comment


              #7
              Originally posted by rodstone View Post
              I SOLVED IT!

              While mucking around trying other things, I found that if you added a SpawnController node, it automatically offers a "convert from actor to pawn" function, so I copy and pasted that into my macro and so now it outputs the actor as a pawn!

              I can only assume this conversion is meant to be offered automatically but this has been a whole evening of frustration trying to make this work!


              Now onto my next challenge, working out how to make an array of my ships. I could do it manually I guess or use a "add all actors with interface" and make sure all my ships have a general interface". Ideally I'd use those tags you can add to blueprints
              Assuming your ships are all the same code class, you can use the "Get all actors of class" node.
              DO contact me with questions about Blueprint or other Unreal features! I don't bite! Or charge money! Just press that blue Skype button and fire away.

              Project Culverin - Open Ended First Person Shooter

              Comment


                #8
                Originally posted by Ray Jones 312 View Post
                Assuming your ships are all the same code class, you can use the "Get all actors of class" node.
                Well that class is pawn, unless you mean, I use the parent class?

                That array will be used, essentially to supply a "shop" with a list of all the potential ships. So it should be an array of classes right? Then the actual array that contains the ships the player "owns" should be an array of objects or classes?

                Because a ship might get damaged, I will need to store that damage information with the ship. Or will I need to store a seperate array that references the ship array like "ship 1 is a ship of X class and has these properties, and this much damage" etc.

                Comment


                  #9
                  Originally posted by rodstone View Post
                  Well that class is pawn, unless you mean, I use the parent class?

                  That array will be used, essentially to supply a "shop" with a list of all the potential ships. So it should be an array of classes right? Then the actual array that contains the ships the player "owns" should be an array of objects or classes?

                  Because a ship might get damaged, I will need to store that damage information with the ship. Or will I need to store a seperate array that references the ship array like "ship 1 is a ship of X class and has these properties, and this much damage" etc.
                  The shop should have an array of classes. The inventory of ships should be and array of objects (which the shop should spawn) since you need to store information about them.
                  DO contact me with questions about Blueprint or other Unreal features! I don't bite! Or charge money! Just press that blue Skype button and fire away.

                  Project Culverin - Open Ended First Person Shooter

                  Comment


                    #10
                    Originally posted by Ray Jones 312 View Post
                    The shop should have an array of classes. The inventory of ships should be and array of objects (which the shop should spawn) since you need to store information about them.

                    Thanks, I thought it might run like that. which is why I have incorporated variables into the parent class like damage, custom colours etc

                    Comment

                    Working...
                    X