x

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"

Change static mesh to other object with UMG button

Hello I am still new in using the Unreal Engine. I start my project with the shooter starter content. After follow a tutorial, I am able to change the static mesh object to another by shooting. This is the blueprint how I set. alt text alt text I want to change the current static mesh object to another by using the UMG button and this is my blueprint. alt text But the button is not working. I know the "cast to destructive wall" need an object reference. In the event hit, the "other" pin will detect whether the object hit is same as the object references cast to. In the UMG button, What should I do to detect and get all the object match to the "cast to destructive wall"? How to change the static mesh to another by only click a button? Really appreciate if get any help or advice! alt text

Product Version: UE 4.20
Tags:
1.png (134.4 kB)
2.png (198.7 kB)
3.png (202.0 kB)
4.png (1.0 MB)
more ▼

asked Nov 28 '18 at 04:00 PM in Blueprint Scripting

avatar image

THEycc
1 1

avatar image THEycc Nov 29 '18 at 07:31 AM

I tried to figure out the problem of the blueprint with color image. This is the widget and the blueprint. alt text alt text If the set static mesh return a false boolean, the image color at top of the gameplay will change to green. I also set the static mesh to movable. Why the set static mesh always return false? alt text

11.png (219.6 kB)
12.png (519.4 kB)
13.png (918.8 kB)
avatar image THEycc Nov 29 '18 at 07:33 AM

I tried to figure out the problem of the blueprint with color image. This is the widget and the blueprint. alt text alt text If the set static mesh return a false boolean, the image color at top of the gameplay will change to green. I also set the static mesh to movable. Why the set static mesh always return false and the object did not change to new mesh? alt text

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

In the first two images, you know that your projectile is actually hitting something, and therefore the Event Hit is triggered.

In this case, where you want to change a static mesh of some actor, the widget doesn't know what actor to change the static mesh on, unless you tell it. You can create a new variable on the widget, and make it of type DestructiveWall (you actually don't need to cast then, as the variable knows what type it is), then on the button click, you'd change the static mesh of your referenced actor. Here's a simple blueprint to show what I mean:

alt text

I've marked the interesting things with orange. You're welcome to ask any questions regarding this solution, and I'll do my best to answer them :)

tmp1.png (95.2 kB)
more ▼

answered Nov 28 '18 at 04:20 PM

avatar image

Detilium
71 3 9 10

avatar image THEycc Nov 28 '18 at 05:22 PM

Hi, thank you for your reply. I followed exactly to the tips you give but it doesn't work :( Is there any mistake on the actor? I am really sure the button can function (tried with set the visibility of button). alt text

5.png (992.0 kB)
avatar image Detilium Nov 28 '18 at 06:45 PM

Do you set the reference variable? Please take an image of the blueprint where you add the widget to the viewport.

avatar image THEycc Nov 29 '18 at 01:24 AM

This is the blueprint of the widget where I put my button. ![alt text I already set the reference variable as below. alt text

7.png (330.8 kB)
8.png (29.6 kB)
avatar image Detilium Nov 29 '18 at 07:07 PM

If you expose this variable on spawn (3rd checkbox in the variable details), you can set the variable whenever you spawn the widget

(comments are locked)
10|2000 characters needed characters left

I figured out why my button doesn't work. Because the object reference did not specify which object is want to change (it is possible to have many same objects). After the object is defined as an array index '0', the static mesh can be set! alt text

14.png (86.2 kB)
more ▼

answered Nov 29 '18 at 04:21 PM

avatar image

THEycc
1 1

(comments are locked)
10|2000 characters needed characters left
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