Scale Blueprints

Hi. Increasing the width of a square is very easy using javascript. Here is the code that increases the width of the square with each click of a button by 5 pixels:

<input type="button" value="Start" onclick="resize()" id="scale">
   
   <div id="cube" style="background: #6a6a6a;width: 100px;height: 100px;"></div>
   
   
   
    <script>
       var x = 100;
       function resize() {
           x = x + 5;  
           document.getElementById('cube').style.width = x + 'px';
        }
    </script>

How to increase the width of the cube with each button click using blueprints?

This blueprint increases the X value after the start of the game.

You have the correct node, you just need to create a widget (if you want a UI button) and connect it to that node or if you want a keyboard button search for the keyboard button by right clicking the event graph in your player character or player controller or level BP (these are the most commonly used BPs to receive player input) and then select the keyboard input event from the list and hook it up to the node you have there.

No. I want to press a keyboard button (for example, button E) to increase the width of the cube. And I do not know how to do it.

Search for “E” in the event graph of the player character/controller and connect it to that node as I show below.

I made in Level Blueprint and everything began to work. I don’t understand why it didn’t work in the Cube blueprint… Thanks a lot for your help !

If the cube is not a pawn/character you don’t receive input events. That is why I mentioned the level, player character/pawn or controller. Anyway, glad it works now :slight_smile:

Thank you. But how to increase the width of the cube each time you press a button usingblueprints? That was my question