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"

How do you reference a StaticMeshActor from within a character blueprint?

How do you reference a StaticMeshActor from within a Character blueprint? I can do it easily from the Level Blueprint using the "Create a reference to" option. However, I don't see that option on the Character blueprint.

Product Version: UE 4.19
Tags:
more ▼

asked Sep 08 '18 at 04:11 PM in Using UE4

avatar image

Corbus Films
1

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

2 answers: sort voted first

If it's separate actor you can create variable with actor and assign it with editor. And then you can do whatever you want.

more ▼

answered Sep 08 '18 at 04:36 PM

avatar image

Przemek2222
426 4 10 14

avatar image Przemek2222 Sep 08 '18 at 06:41 PM

You can use Get all actors of class BL node and just search for you StaticMeshActor. Tell me what exactly you want to do and I will think about best way.

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

to reference an actor that is outside of the character you will need make your own method to aquire the reference there is not one built in like there is for the level bp. this is because you could have your character in many levels but the other actor will only exist in one level. there are many ways to get a reference though so it shouldn't be too hard. I'll mention three methods here, public variable, traces, searching.

first comes the public variable method which is good for when you place your character in the level and the other actor already exists in the level as well and when its a set item that wont be changing. to make this setup you create a variable in your character then click the eye icon next to the variables name so that it appears open, this makes the variable public. the variable being public means that you can modify its value by selecting the character and changing the value in the default section of the details panel. the last step is to set the type of the variable, actor should be good to start but you may want to narrow it down to a more specific type later.

the next method is to use a trace. a trace basically projects something (usually a line or shape) from one point to another and tells you if it hit anything along the way. we can use this to project a line from the character to a point 500 units in front of the character and if the trace hots something it will be returned so we have a reference to it. think of it like walking in a dark room with a stick in front of you, then when your stick hits something it lights up so you can tell what it is. ill link the doc on it for you to peruse.

https://docs.unrealengine.com/en-us/Engine/Physics/Tracing/Overview

the last method can be a very good one when used correctly, but many people use it incorrectly which results in poor performance and unreliable results. this method consists of using something like the get all actors of class node which as you probably guessed returns all the actors of a specified class (you specify) as an array. you can then take this array and apply conditions to narrow down to the item you want. and example of this would be if you wanted to get the closest enemy to you character. then you could get all actors of class enemy, then you would take the array and run it through a loop which checks the distance from the character to the enemy and returns the one with the shortest distance. note though that you should never do as many people do and use a get all actors of class then a get index 0 node, this will not always return the same object making it unreliable and its a un-performant way to accomplish the task.

along the same lines as the get all of class there is also the get all with tag and the get overlapping actors.

more ▼

answered Sep 08 '18 at 06:33 PM

avatar image

ThompsonN13
10.1k 33 10 25

(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