Announcement

Collapse
No announcement yet.

RTS Control in Blueprint?

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

    RTS Control in Blueprint?

    Just downloaded UE4 last night, and went through all the blue print videos today. Very fascinated by it all, and would really enjoy learning more about everything and maybe working on a couple of prototypes. With that in mind, the first thing I was wanting to learn how to do was move objects, in the mind of working on a RTS.

    I'd like to start off very basic, so if I had a static mesh, how would I go about selecting it in game with a mouse selection and move it from it's current selection to the new location selected using the mouse in game?

    Thanks!!!

    #2
    I apologize in advance for the bad layout in the image below. I've messed around a bit more, and am now able to get a static mesh to rotate (decide to start with rotation as it would be easier to track on screen).

    With that being said, the mesh is rotating at an exponential speed instead of an incremental step of 1. What am I doing wrong?

    Thanks!

    Comment


      #3
      I think you only need to do something like this, which will rotate the mesh by 90 degrees per second:



      In your current graph the amount you rotate (NewVar0) is actually increasing each tick.
      Lead Programmer - UE4 Animation/Physics/Audio Team - Epic Games
      Twitter: @EpicJamesG

      Comment


        #4
        Thanks James, I'll give that a try tonight. Quick question though, what is Delta? I've seen Delta Seconds, Mouse Delta, Delta Rotation and some other places. I'm a bit confused with what it is and how it's used.

        Thanks Again!
        -Mike

        Comment


          #5
          'Delta' usually just means 'change in'. So 'Delta Seconds' is the time since last frame, 'Delta Rotation' means the change in rotation you want to apply. Because frame rates can vary, you need to take the frame time into account so your object moves at a constant speed.
          Lead Programmer - UE4 Animation/Physics/Audio Team - Epic Games
          Twitter: @EpicJamesG

          Comment


            #6
            Very cool, and good to know. That cleans things up quite a bit. Another question, why is delta seconds bing linked into the Z 90?

            Also, if you wanted to say have it complete a 360 spin say every 1 second for a constant speed instead of based off of ticks how would you set that up?

            Thanks again!
            Mike

            Comment


              #7
              It is a cross product rule .

              You want to rotate by 90° per sec. You want the deltaAngle to apply to your object each frame, so you multiply the angle speed by the deltaTime which is the time since last frame.
              The node that connect angle speed and the delta time is a multiply node, that why it is connected together.

              With this setup, it is already at a constant speed, it is not based only on tick because the deltaTime is part of the equation !

              If you want to rotate by 360° per sec, just change Z 90 to Z 360.

              Comment


                #8
                Thanks Cripple, I think I have my head wrapped around it now.

                I'll be giving this a try tonight, along with some other things!

                Another quick question Last night I was able to set the transform information to the mouse's XY location, however when I'm in play mode, the mouse acts as the camera so when I move the mouse the viewport changes. What would be the best way to un-link the mouse to the viewport movement, and display the mouse cursor so I can click on a location and move a static mesh to the location?

                Thanks!

                Comment


                  #9
                  So I've looked at the mouse interaction content example and can't seem to determine how to turn the mouse cursor on in a new project/level and how to use it for interaction.

                  Currently when I hit play, the mouse cursor stays hidden and when I tag the left mouse click to print mouse location it prints out 0, 0, 112. And no matter how much I move my mouse the position stays locked to this position.

                  What am I missing?

                  Thanks!

                  Comment


                    #10
                    Turns out I was missing the game mode setup from this tutorial. https://docs.unrealengine.com/latest...ace/index.html

                    I am now able to record the hit results from under the mouse when I left mouse click.

                    Comment


                      #11
                      To make a mouse input based game you need to make a new Game Mode Blueprint, and a new Player Controller Blueprint.

                      Open the Player controller Blueprint, and go to the defaults tab and check all the relevant checkboxes that you want under Mouse Interface. Touch is referring to touch devices like smart phones or tablets.

                      Open the Game Mode Blueprint and under Player Controller Class click the dropdown and select the one you made.

                      Now we need to tell the level to use this Game mode, to do that, go to the World settings (the earth icon at the top), and find Game Mode section, now under GameMode Override click the dropdown, and set it to the Game mode you made.

                      Now when you play you should have mouse input.

                      Click image for larger version

Name:	MouseInput.jpg
Views:	1
Size:	101.4 KB
ID:	1049888

                      Comment


                        #12
                        Got a good start on moving objects now. By using the tutorial for setting up the Interactive Mouse Game Mode from here - https://docs.unrealengine.com/latest...ace/index.html

                        Creating a mesh, and making sure it's changed from Static to Moveable

                        And by using the blueprint below.


                        I think the next step will have it moving instead of jumping to the location. I think I've actually got a halfway idea of how to do that too

                        Comment


                          #13
                          Thanks Shane, I must have been going through that tutorial and posting right as you posted!

                          Originally posted by Shane Caudle View Post
                          To make a mouse input based game you need to make a new Game Mode Blueprint, and a new Player Controller Blueprint.

                          Open the Player controller Blueprint, and go to the defaults tab and check all the relevant checkboxes that you want under Mouse Interface. Touch is referring to touch devices like smart phones or tablets.

                          Open the Game Mode Blueprint and under Player Controller Class click the dropdown and select the one you made.

                          Now we need to tell the level to use this Game mode, to do that, go to the World settings (the earth icon at the top), and find Game Mode section, now under GameMode Override click the dropdown, and set it to the Game mode you made.

                          Now when you play you should have mouse input.

                          [ATTACH=CONFIG]115[/ATTACH]

                          Comment


                            #14
                            man, i feel a little spoiled by having the UE devs actually posting. you guys rock!

                            EDIT: hey sandman? i'll be watching this thread too as i'm extremely interested in the same.

                            Comment


                              #15
                              Alright, so I've spent the morning trying to figure out put some movement in between the jumping

                              At the moment what I have below will allow the mesh to move along the x axis either up or down depending on if I click above or below the object. However, I'm also trying to get it to stop, and it's not working at the moment, for some reason it's not reading when the mesh equals the same location of where the mouse click was. Any help would be amazing! Thanks!!!


                              Comment

                              Working...
                              X