Announcement

Collapse
No announcement yet.

Spawn Point Location

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

    Spawn Point Location

    I am using a menu system to spawn items but I have to create a variable and put in the exact location of where I want to spawn the item in the world as you can see in the screenshot below. The only problem is this won't work if I want to use that same menu in different levels because the location won't be the same. Is there any other way to do this. Is there some actor I can create put it into the world and tell the spawn actor in my menu I want to spawn to that point. I'm guessing because you would be using two blueprints one for the menu and one for the actor you put in the world you would need to use blueprint communication but I've looked up tutorials on blueprint communication and I can't find any that will help me with this problem. Does anyone have any idea on how I could do this?


    #2
    Is there some actor I can create put it into the world and tell the spawn actor in my menu I want to spawn to that point.
    Solution 1 - have an array/map (dictionary) with spawnpoints for each level. Keep it in the game mode / game instance
    Solution 2 - have a transform variable in the level and have the level bp call the widget (whose reference you must be keeping in one of the framework classes, surely)
    Solution 3 - have a spawner actor (just a regular actor) in each level with a tag and pertinent variables a widget can query and fetch data from

    Comment


      #3
      Originally posted by Everynone View Post

      Solution 1 - have an array/map (dictionary) with spawnpoints for each level. Keep it in the game mode / game instance
      Solution 2 - have a transform variable in the level and have the level bp call the widget (whose reference you must be keeping in one of the framework classes, surely)
      Solution 3 - have a spawner actor (just a regular actor) in each level with a tag and pertinent variables a widget can query and fetch data from
      Thanks for your reply. So out of the 3 solutions, you give its the 3rd one I am trying to do but that's where I am getting stuck. As I said I know I need the actor to communicate to the widget or as you said "with a tag and pertinent variables a widget can query and fetch data from" but I don't know how to do that?

      Comment


        #4
        Give the spawner actor a tag, have the widget get all actors with tag, get 0 > cast.

        The tag is called SpawnerAnchor:

        Click image for larger version  Name:	Capture.PNG Views:	1 Size:	20.7 KB ID:	1528474

        So a widget can do this:

        Click image for larger version  Name:	spawner.PNG Views:	1 Size:	45.2 KB ID:	1528478

        This would be my least favourite method, as everything with Get All of Something. But it's the easiest to implement and should work well enough for this, actually.

        Difficult to advise more precisely without knowing how many levels you've got, how one transitions, whether it's procedural.

        What I'd do, I'd have a custom event in the GameInstance create the widget and call it from the Level Blueprint, feeding the widget LB's data. Again, this might be unsuitable depending on how your levels work.

        So, you load the level, get GameInstance, call that event and pass the transform as an attribute.
        Last edited by Everynone; 09-16-2018, 06:08 PM.

        Comment


          #5
          Originally posted by Everynone View Post
          Give the spawner actor a tag, have the widget get all actors with tag, get 0 > cast.

          The tag is called SpawnerAnchor:

          Click image for larger version Name:	Capture.PNG Views:	1 Size:	20.7 KB ID:	1528474

          So a widget can do this:

          Click image for larger version Name:	spawner.PNG Views:	1 Size:	45.2 KB ID:	1528478

          This would be my least favourite method, as everything with Get All of Something. But it's the easiest to implement and should work well enough for this, actually.

          Difficult to advise more precisely without knowing how many levels you've got, how one transitions, whether it's procedural.

          What I'd do, I'd have a custom event in the GameInstance create the widget and call it from the Level Blueprint, feeding the widget LB's data. Again, this might be unsuitable depending on how your levels work.

          So, you load the level, get GameInstance, call that event and pass the transform as an attribute.
          When I try this though I get an error in the spawn actor (which you can see in the picture below) because something needs to be plugged into the spawn transform but I can't plug in the spawn point ammo var because that is giving a precise location point which I presume would override the cast to node.



          Comment


            #6
            You might need to split the spawn transform so it is default 0,0,0

            Comment


              #7
              You might need to split the spawn transform so it is default 0,0,0
              No, no, don't do that. How would that help? The idea here is to have a spawn helper object in each level, that object stores information about spawn locations for other objects.

              @tcla75: The object you've cast to (SpawnWeapon) is supposed to hold the data. Store the Spawnpoint Transforms there, ideally in an array so you can spawn multiple ones in one go if that's what you want.

              edit:

              Also, now that I understand what you're trying to do (somehow I didn't get the scope of you're trying to achieve from your description) I can suggest another solution - a data table, probable the most efficient one. You can have a struct with all the data you need for each level. Since data tables are available globally from anywhere, you can fetch their structs directly from the widget and get access to spawnpoints (and other data) without helper objects or casting. Best of all you can set most of the data in a word processor as using the DT's editor is somewhat painful.

              Up to you, though - all the suggestions I mentioned would work fine.
              Last edited by Everynone; 09-17-2018, 03:02 AM. Reason: added more options

              Comment


                #8
                Originally posted by Everynone View Post

                No, no, don't do that. How would that help? The idea here is to have a spawn helper object in each level, that object stores information about spawn locations for other objects.

                @tcla75: The object you've cast to (SpawnWeapon) is supposed to hold the data. Store the Spawnpoint Transforms there, ideally in an array so you can spawn multiple ones in one go if that's what you want.

                edit:

                Also, now that I understand what you're trying to do (somehow I didn't get the scope of you're trying to achieve from your description) I can suggest another solution - a data table, probable the most efficient one. You can have a struct with all the data you need for each level. Since data tables are available globally from anywhere, you can fetch their structs directly from the widget and get access to spawnpoints (and other data) without helper objects or casting. Best of all you can set most of the data in a word processor as using the DT's editor is somewhat painful.

                Up to you, though - all the suggestions I mentioned would work fine.
                Just explaining the error...

                Comment


                  #9
                  Originally posted by Everynone View Post

                  No, no, don't do that. How would that help? The idea here is to have a spawn helper object in each level, that object stores information about spawn locations for other objects.

                  @tcla75: The object you've cast to (SpawnWeapon) is supposed to hold the data. Store the Spawnpoint Transforms there, ideally in an array so you can spawn multiple ones in one go if that's what you want.

                  edit:

                  Also, now that I understand what you're trying to do (somehow I didn't get the scope of you're trying to achieve from your description) I can suggest another solution - a data table, probable the most efficient one. You can have a struct with all the data you need for each level. Since data tables are available globally from anywhere, you can fetch their structs directly from the widget and get access to spawnpoints (and other data) without helper objects or casting. Best of all you can set most of the data in a word processor as using the DT's editor is somewhat painful.

                  Up to you, though - all the suggestions I mentioned would work fine.
                  Thanks so much this has really helped

                  Comment

                  Working...
                  X