I’m having a bit of trouble having more than one of a specific object in scene working at the same time.
To put it in perspective I’m wanting to make a supermarket shelf where I can change the whole line of product colours at once (So the client can see how different flavours look). I’ve made one product where I can cycle through the colours and keep cycling with the press of a button, but if I add another next to it, only the newest copy works, so it’s looking a little lonely on the shelf at the minute!
I don’t really understand why it wouldnt work, it needs the same keypress to do what it needs to do but it will only do one.
Any help would be much appreciated
1 Like
Hi,
first i want clarify common things for you and how code work, lets say for example you have actor based blueprint called “BP_apple”, inside this blueprint you have static mesh and mesh have inner native (not variable) texture/color property
then you place 3 “BP_apple” on shelf, let’s assume you don’t have any other instances of “BP_apple” somewhere else (but note that you still can have different instances anywhere esle and still make code working in way to affect only right groups of actors)
in single player game
you can simply use “get all actors of class” and specify “BP_apple”, after this use “for each loop” and iterate over every single instance of “BP_apple”, to change mesh color inside blueprint you should understand, that mesh texture/color if property only of mesh and not whole blueprint, so to access inner component you have to use function “get child component (mesh)” and then you can use returned value as reference to mesh of exact instance of “BP_apple” and change it’s color/texture
in multiplayer game
whole algorythm mostly the same, but if you want make each player see different color you have to make custom event with replication type (on right in detail tab) “run on owning client” and call it from your character blueprint, because then every client wll have his own character blueprint and such function will run locally and makes no changes on server
p.s. don’t forget mark question as answered when problem solved, so anyone else later can have same question and may find solution faster
Hi, I’m fairly new to all this so sorry for being a bit naive. I’m not sure I fully understand, do you have a screenshot of where I should be setting the “get all actors of class”, do I put this in the level blueprint or the actor blueprint. My blueprint is set up with dynamic material instances through a multigate so would I have to use the “get child component” function?
Thanks
Hi,
right answer depend on realisation, so i’ll try cover most common situations:
- this is common for both (single and multiplayer) “get all actors of class” should be used in character blueprint or your custom player controller after player’s action that should change items’ color, for example event “E key button” (of course this is just idea and doesn’t cover full code logic, like checking if you enough close to shelf or can perform this action currently)
- if you gonna make multiplayer game and want each player see different colors at same time, then you can make hidden item holder with variable to hold actor and maybe even count to show apples for example as pyramid, this hidden item holder should have replication enabled, after this you need “custom event” with replication type “run on owning client” (it can be called from event “begin play” and check with “switch has authority” = remote), inside this custom event you can create actors from variable in hidden item holders and change their look localy because they won’t be created on server and replicated, cosmetic workaround because UE4 yet doesn’t support flexible replication options
Hi, im still really stuck with all of this, i’m still not getting it. I’ll just clarify that I’m not looking at making a multiplayer game, im using the first person template to simplify it for me but I dont know what to connect to what now. See my screenshot for where I am, I’m getting plenty of error messages as you can see and I’m struggling a bit
Thanks again
This is my blueprint setup which i’m trying to instance, can anyone shed any light on why the E key wont work for every copy of the blueprint, considering that they are exactly the same.
Thanks
Solved it!!
untick consume input and it works perfectly
alt text
1 Like