Announcement

Collapse
No announcement yet.

How can i cast to desired blueprint?

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

    How can i cast to desired blueprint?

    I have made grid blueprint, construct event looks like this:
    https://i.imgur.com/LrMcZo2.png
    All it does is making a grid out of static meshes, grid itself: https://i.imgur.com/eDGYpsU.png

    Now inside my gamemode i want to handle logic of spawning boxes on this grid, what should i use to make it work?
    https://i.imgur.com/AISJJM8.png

    #2
    So, you have the grid in the world, and now you want to spawn boxes over it's surface, yes? Are these boxes static meshes or BPs?
    "I have harnessed the shadows that stride from world to world to sow death and madness."

    Comment


      #3
      They are BPs (i guess?).
      https://i.imgur.com/lxwI52I.png
      https://i.imgur.com/uS6fNc7.png

      Yes, I want to spawn box on surface, the script is already done and working https://i.imgur.com/Eody7FL.png inside grid blueprint, but I have read that gamemode/gamestate on server side should keep track of those things and perform action, e.g. if there are no boxes on the grid spawn one, or if time left is 30s or less, spawn at least two boxes etc.
      So I've made SpawnBox custom event inside grid blueprint and now i want to call that event from gamemode BP.

      Comment


        #4
        Originally posted by Tafonath View Post
        So I've made SpawnBox custom event inside grid blueprint and now i want to call that event from gamemode BP.

        There are several ways to it.

        1 - In the gamemode, you get the grid reference, using for example, "Get All Actors of Class", get the first element of the array, cast it to PogoPainter_BP. Now that you have a direct reference to the grid, you can directly call "SpawnBox".

        Click image for larger version  Name:	spawn.png Views:	1 Size:	56.3 KB ID:	1462306

        2 - using event dispatchers.

        In your gamemode, create an event dispatcher, which I called "SpawnBox" (don't use this name, because it's the same name as your Spawn event in the Grid BP). Then setup the system that will trigger the spawn - in my case, I setup a timer that will call "SpawnBox" every second:

        Click image for larger version  Name:	gamemmode.png Views:	1 Size:	52.4 KB ID:	1462308

        In your grid BP, bind your "Spawn" event to the event dispatcher:

        Click image for larger version  Name:	grid.png Views:	1 Size:	163.6 KB ID:	1462307
        "I have harnessed the shadows that stride from world to world to sow death and madness."

        Comment


          #5
          I knew i did it before, I had some brain lag and tried to cast directly to class instead do it the way you showed.
          Thanks works perfectly!

          Comment

          Working...
          X