Announcement

Collapse
No announcement yet.

Noob asking: How to move unit on a grid based system

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

    Noob asking: How to move unit on a grid based system

    Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	249.0 KB
ID:	1138577
    Hi everyone,
    I have a grid spawner(Actor blueprint) class that spawn a gird of planes, and I would be able to get the location of each plane when I hoover my mouse over them.
    However, I do not know how to pass that vector date into the Pawn class, so that the Pawn class could use it as the destination of it's movement.

    Also, What is the best way to handle grid based movement? basically I want to achieve kind like FF tactics/ heroes of might and magic style movement system.

    Please reply with anything you think can point me to the right direction, although I do not have a coding background, I am eager to learn and I see blueprint as the first step of my long long UE4 journey.

    Thank you very much.
    Last edited by Adam Korle; 09-16-2014, 12:34 AM.

    #2
    Hello,
    When you create your grid, you have an index. Create a variable in the actor (integer) and store index valuet as "plane number".

    Comment


      #3
      Originally posted by Fen View Post
      Hello,
      When you create your grid, you have an index. Create a variable in the actor (integer) and store index valuet as "plane number".
      So to update that variable in your pawn, you can go about it several different ways. I am assuming your pawns will spawn into the game after the map. So inside your pawns you can create variables and set those to be "Exposed on Spawn" in their details panel. Then, when you use the spawn actor node, it will have those variables exposed as inputs. Then when you spawn them using Spawn Actor from Class node, you can pass the grid data and anything else to them.

      If you need to do this after they are spawned(which you will probably have to do at some point either way), then Cast, Interfaces, and direct blueprint communication are the 3 mains ways to do that. The unreal documentation covers all 3 methods in detail.

      As for the actual movement of them, I think updating their vectors based on a timeline might be the way to go but I haven't worked that part out myself so there are probably a few other ways to do that as well.
      Map Generator 1.0
      Map Generator 2.0
      Map Generator 3.0

      Comment


        #4
        I have also tried to do something, but for now I can not figure out how to interact with the grid plane.
        With a picture is best understood:
        Click image for larger version

Name:	FyexdFK.jpg
Views:	1
Size:	340.4 KB
ID:	1056755
        I have basically created my pawn (the red small square) you can move with mouse,gamepad or keyboard, my problem is this how do I do interact with each square of the grid?
        I tried a variant with the trigger box but it is too intricate and inaccurate.

        Comment


          #5
          It depends what you want to do but basically, in square blueprint : On over event : visual effect and store a bool info "this square" and on click event : cast to character custom event "move there" and do in bp custom event "move there" with square location as input. (bool will be usefull when you'll have more choices. (don't forget to set this bool to false on click)

          if you want use line trace check this : https://forums.unrealengine.com/show...ght=line+trace
          Last edited by Fen; 09-16-2014, 06:20 AM.

          Comment


            #6
            Thanks a lot Fen, This is exactly what I was looking for, even if it seems a little intricate ^^
            I'll get right to work and see what I can do.

            Comment


              #7
              Hi everyone,
              Thank you all for the awesome replies. I'm gonna dive into blueprint communication, and see if I make some progress from there.

              Comment

              Working...
              X