Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Scaling a Plane (StaticMeshActor) in the X Axis with a Slider

Hello there!

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.

alt text

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:

alt text

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:

alt text

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.

Product Version: UE 4.20
more ▼

asked Apr 30 '19 at 02:04 AM in Blueprint Scripting

avatar image

15 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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:

alt text

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:

alt text

Image from Gyazo

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:

Image from Gyazo

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.

slider.png (123.3 kB)
lb.png (261.3 kB)
more ▼

answered Apr 30 '19 at 09:02 AM

avatar image

15.2k 77 25 62

avatar image GregPD2Game Apr 30 '19 at 03:59 PM

Ooh, sweet. Let me try that and get back to you, because I think this is what I need. Scaling one way instead of both ways is definitely fine for now. Thanks so far!

avatar image GregPD2Game Apr 30 '19 at 04:35 PM

Got it! I was wrong; it does scale in both ways, because I'm scaling the plane itself where the pivot is placed in the exact center of the plane, and not on one end of a road. I think to place the pivot there, I need to nest the road into an empty object and set the position of the road itself respectively. (Unfortunately, that does require changing the blueprint a print so that I am scaling the parent object itself and not the road mesh itself.)

avatar image GregPD2Game Apr 30 '19 at 04:35 PM

Thank you so much!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question