Hi, there’s this game I’m working on and I’ve hit a stumbling block. The problem is I have some actors, specifically weapons, which the player can pick up. As the player picks it up, it gets added to an array. Now I’m trying to get the skeletal mesh of the actors picked up but for some reason I can’t, I need to make use of the sockets on the actors, I used 'get all actors of class ’ but it affects also actors that weren’t picked up. Any help would be appreciated, thanks.
I used 'get all actors of class ’ but it affects also actors that weren’t picked up.
That’s normal. Don’t. Avoid that node unless you actually mean ALL.
As the player picks it up, it gets added to an array. […] for some reason I can’t
This explanation does not cut it, sadly. What exactly is stopping you from accessing the array you’ve added the skeletal mesh actors to?
- where is the array? In the player BP?
- what (which actor) is trying to access that array and how?
- what have you tried?
Thanks for replying, the array is set up in the player blueprints, the player bp is the one trying to access the actors in the array and as for what I’ve tried, alot actually , I even went as far as attaching the said weapons on the character and enabling their visibility true only when the index in the array matches that on an index I define when the character picks them up.
To elaborate more, what I want is for the player to be able to pick up weapons, now these weapons get added to an array which is a variable in the player bp and I want to be able to retrieve the skeletal meshes of these weapons in the array. I used a for each loop for each individual weapon when picking them up and I promoted the return value of the for each loop to a variable which I named " ‘nameofWeapon’_ref". Now each of these variables from the different for each loops are what is being added to the array. I don’t know if these all makes sense, I’m not currently using my PC, I would have sent a couple of screenshots
To be a little clear, I can access the array and references without any issues, it’s just that when I get the references, note their type is actor, I drag off of them and type skeletal mesh buh nothing comes up
You made the array of actor type → you’ll need to cast to the type you want. Or make the array of the type you want to start with.
- if the array is of actor type, you must cast:
- if I start with the array type like so:
No need to cast.
You mentioned the items were Skeletal Mesh Actors
, Add
them like so:
I’m confused a bit you’re using the make array node, is it possible to create an array as a variable and then add them to that array?
Already up there. The last bit.
Thanks for the help so far, looking at the script it seems like something that could work, but one problem tho
The actors are spawned in the world, I added an interface to them so I can use that to specify what actors exactly I’m looking for, now the player is only able to pick them up when he’s overlapping them so I use “get overlapping actors of class” and “does contain interface” as a condition
I’m going to try ur method but how do I go about getting when the player overlaps them, I could use a collision that I can create in the actor bp but I wanna know if there’s a better way to achieve that, just ur advice on it.
for the player to be able to pick up weapons, now these weapons get added to an array which is a variable in the player bp and I want to be able to retrieve the skeletal meshes of these weapons in the array.
when the player overlaps them, I could use a collision that I can create in the actor bp
The player’s capsule can overlap the items, or you can add another (larger?) component that will scoop things up.
- in the player:
The player overlaps an item and adds it to their array. Whether you use an interface does not really matter here. But can be super useful as a method of filtering and triggering other stuff, ofc. The interface can return the item.
Hmm I see🤔
Can I get the exact actor currently in the array, like the name, class or anything unique to it because I don’t want the player to be able to pick up a weapon which is already in the array
If I use a copy of the array and find item, how am I to get the reference of the item I’m looking for?
- lets say this is the BPI:
- implementation in the item:
I don’t want the player to be able to pick up a weapon which is already in the array
- player collects UNIQUE stuff only:
There’s a plethora of other considerations, ofc. As in, what else we’re interacting with.
If I use a copy of the array and find item, how am I to get the reference of the item I’m looking for?
How would you like to look up the items? By name, by ID, by instance, by tag, something else? Have a look at the:
It’s a container that would allow you associate Names with Actor and retrieve them Instantly.
By class
That’s possible right?
Yes, you can make a Class | Actor map. Have a look at the link I posted above:
It could look like so:
It could also be done better, I was rushing it. ;p
I see, thanks alot, if I run into any stops I’ll get back to you, have a wonderful day
Thanks it’s working now, all I simply did was to cast the actor that I’m picking up to the actors I need and promote the cast to a variable, the get the skeletal mesh from there, wouldn’t have figured it out without you, thanks alot
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.