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"

Attach array of actors to another array of actors

Howdy! Well, i have a Spawn Volume that spawns randomly meteors all arround the spawn (its a spaceshp universe so there's no floor) and you have to shot the meteros and destroy them, pretty simple. The thing is that i want to add the life of the meteors, so you can see how many bullets do you need to destroy them. I've done this adding a widget into the meteor actor and update every time that the players looks at it, or shots, but its kinda annoying because the widget rotates randomly with the meteors (so, sometimes the hp bar is inside the meteor looking at you, or in a side, or behind, or you just can't see it... ) And what i want to do, is have this hp bar just up in the meteor, looking at you, but i can't create this into the meteor bp (i think) because it will rotate. What i've done this far, is create another actor, which is only a widget, and try to spawn it the same times as the meteors, and then attach them into the meteors.. but is not working, and i think im messing up this. Thank you! And sorry for my english, its not my native lenguaje!

Product Version: UE 4.15
Tags:
more ▼

asked Apr 12 '17 at 08:34 AM in Blueprint Scripting

avatar image

Nøshari
1 2 3

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

2 answers: sort voted first

Adding a widget component to your meteor BP or attaching an actor with only one widget component to your meteor BP shouldn't make any difference. I would try to update the widget component world rotation at the tick event of the meteor BP. I don't know the local directions of your widget (i.e. is the x-axis point up, or right, ...), but you can create a rotator out of two axis. So when I assume that the widget's local z vector should point upwards and the x vector should point towards the player, then use the "Make Rot From XZ" node, plug in the global Z vector as Z and the player's world location minus the widget's world location as X, and use the rotator for Set World Rotation Of Component for the widget. I hope this helps.

more ▼

answered Apr 12 '17 at 09:01 AM

avatar image

Benergy
806 21 4 27

avatar image Nøshari Apr 12 '17 at 09:12 AM

That is what i have from the BP meteor, this is inside the function ''Follow character'' which is called with the event tick only when its created. I think i know what you mean but i don't know how to do it. alt text

meteor_bp.jpg (77.8 kB)
avatar image Benergy Apr 12 '17 at 02:01 PM

Does your function not work? I'm afraid I don't understand the problem.

avatar image Nøshari Apr 13 '17 at 12:18 PM

Its working but not the way i want, i want to have a hp bar for each meteor that stays at the top of the meteor and does not rotate with it. So, i was thinking about creating another blueprint, and ataching every one to the meteor blueprint... or something like that

avatar image Benergy Apr 13 '17 at 01:33 PM

That's why I suggested to use the Make Rot From XZ node. In addition set the world position based on a predefined relative offset, like this: alt text

screenshot.png (147.6 kB)
avatar image Nøshari Apr 15 '17 at 03:42 PM

okay i'll try this and let you know. Anyway, what's exacly the 'Health widget world offset' variable? thanks

avatar image Benergy Apr 15 '17 at 03:54 PM

That's just a new variable I created for this actor.

avatar image Nøshari Apr 16 '17 at 04:41 PM

what kind of?

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

You should try to see the results by using only a Widget and screen space. There are two ways to tackle this.

The first one is by simply using your main HUD class. Get all the meteor actors and project their world location to screen location so that you get the location in screen space where you will draw their health bar. You can additionally filter by their position on the screen so any meteor that is not on the screen will be left out. You could also move the health bar above the meteor (in your case in screen space since they're rotating in world space). Example:

alt text

The second is a bit more complicated. You should create a separate Widget that will contain the health bar itself, and then in a similar fashion spawn it above the meteors, but this time from your main HUD widget. You should create a canvas element that has full screen size in your main widget and then on construct spawn the health bar widgets and parent them to the canvas. The health bar widgets should have an actor variable (could also be meteor) that should be passed on spawn, which will be the connection between the widget and the meteor actor. Then in the health bar widget on tick just take the actor location project it to screen space and translate the health bar element to that position. You could also filter this position as it may be off screen.

I haven't tried this yet on this specific example, and I don't have the time now, but it has worked for me in the past. If you can't figure it out by yourself I will post a blueprint screenshot later.

screenshot_1625.png (199.1 kB)
more ▼

answered Apr 16 '17 at 02:39 AM

avatar image

neelix32
149 2 3 7

avatar image Nøshari Apr 18 '17 at 07:51 AM

I tried this but it doesn't seems to work, my 'draw text' is different compared to yours, i've been trying and i dont know how to solve this

avatar image neelix32 Apr 18 '17 at 04:17 PM

There are 2 types of DrawText you have to get the one where the target is HUD.

(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