How to change object size by pressing key?

How can I add an interaction that rescales the object size while in the game? I want to be able to change an object’s size by pressing different keys; for example, if I press A, the object would increase his size in axis X and Y, and if I press D, the size would decrease. I haven’t found any reference or tutorial on how to do this. Thanks in advance!

I believe there should be a blueprint node along the lines of “Set Actor Scale” which you should be able to use for this.

Basically you’ll want to add the input buttons (project settings, input, action key events) then go into your player blueprint and search the name you gave to those inputs; this will allow you to create an event that gets called when a player presses a specific button. You could then call the Set Actor Scale node directly from that event or use the event to set a boolean to true when pressed and false when released. This will then let you set up a branch (if statement) that uses those boolean values as its condition which will then let you call the Set Actor Scale function.

If you need me to rephrase or you get stuck further just let me know and ill see what i can do.

Hi! Thanks a lot for your help! I was able to create the input buttons and find the “Set Actor Scale 3D” node in the player’s blueprint, but from there, I don’t know how to connect this node to the object I want to modify. The object it’s a cylinder brush, but I guess I could use another type of object like a static mesh or something else if it’s necessary. I was also wondering if it was possible to make the input button always increase the size of the object by X amount, instead of changing it to a specific size. Sorry if these questions have really obvious answers, I just started with UE4 a few weeks ago. Thanks again!

Im not sure if you can change the size of brush’s like that; but im pretty new to UE myself so i could be wrong and yes you can change have it increment rather than set to a defined value just have it set its scale to its current scale plus whatever, so: NewScale = OldScale + 1; or something like that.

Everyone has to start somewhere man :slight_smile:

Hello, you just need a reference to the object. How to get that reference varies:

You may have a Blueprint with an Actor Reference variable, but you should check it is valid before doing anything else, otherwise the Editor will crash trying to acces a parameter of a Null Reference.

You can also have a reference to the object you want to modify in the Level Blueprint, and do everything from there.

This can evolve a lot. You may even have a key that when you press it, gets the first Actor you are aiming to, sets the Actor Reference to that one, and then you get its scale, modify it, change to another actor reference… etc etc.

Here you have some example images:

If you only use the Level Blueprint:

http://puu.sh/iLmbl/e0357758e3.jpg

OR if you want to make it from your Character Blueprint:

http://puu.sh/iLmMh/881b9b1eaf.jpg

Character Blueprint with an editable Actor Reference variable (and an editable vector amount to add to the scale).
When I say editable, I mean the variable is public and you can set it in the Details of your blueprint (remember, that’s when you check the little eye next to the variable name in the My Blueprint panel).

http://puu.sh/iLmvi/bf19b7f6ca.jpg

Hi Suui, thank you so much for your help! The pictures were really helpful and made it easy to understand. I’m truly grateful. Thanks again :slight_smile:

I’m glad it helped :wink: Be sure to keep learning and make a nice project sometime!