Scaling a Plane (StaticMeshActor) in the X Axis with a Slider
I am completely new to using Unreal Engine 4; please bear with me if I am not familiar with how this works quite yet, as I am learning some new skills. I used to do some projects a few years before with Unity, but for this university project I'm working on as part of finishing my bachelor's degree, I chose UE4 because it delivers photorealism and offers a nice opportunity for me to practice C++ programming.
Anyway, I'm building, on an agile basis, a scenario generator for a student design team at my university on autonomous vehicles.
I have a simple plane here, with no textures applied to it, that I would like to scale while the application is running.
To start out, I want to use a slider placed at the top left corner to adjust the length of this "basic, transparent road." This is done by adjusting the scale of the plane on the X axis; for now, just between 10 to 100 meters. The UI blueprint looks like this:
Right now, I need to add an OnValueChanged event listener so that when I move the slider back and forth from left to right, it sets a new scale value for the X axis of the plane. What I don't know yet are what nodes I need to use in order to get the plane's current scale, as a vector, set the X axis independently, then reassign it back to the actor. This is my blueprint so far:
All it does is it only takes the value of the slider and transforms it to a value between 10 to 100.
Do you know what I need to do next? Any helpful documentation and lessons I could perhaps check out? UE4 looks much more complicated than Unity, but it really helps me with my skills as I'm new and keen to this.
asked Apr 30 '19 at 02:04 AM in Blueprint Scripting
Here's the most basic implementation:
The widget with the slider calls its own Event Dispatcher and sends Slider Value to any object that will register with this event:
In the Level Blueprint, I manually dragged & dropped a reference to the Floor from World Outliner:
Begin Play adds the widget to the viewport and binds the widget dispatcher call to an event in the Level Blueprint:
The rest is getting the scale from the Floor reference and setting it back to what the Map Range node spits out. It scales only one way here because the pivot in the blank template I used it set up like that:
If something does not add up, do tell.
tip: you can right click pins and split them (break them into components) - like the vector of Get Actor Scale 3D node above.
Follow this question
Once you sign in you will be able to subscribe for any updates here