What's the best way to handle multiple objects in Multiplayer?

Hi there,

i am working on a new Project. It’s a coop game like Resident Evil 7 mixed with Alan Wake. The campaign is designed for coop but also for singleplayer. Now i have some questions and hope someone can give me a hint how i set up some things.

What’s the Goal? I have several objects the Players can interact with.

  • Doors
  • Lights
  • Switches
  • Switches with Password to unlock some objects like doors, or lockers
  • Pickups

For now all things are working. Each Player (Server or Client) can pickup items (1 for now), toggle the lights over a Switch, enter a Password to unlock doors or shoot at the lights do destroy them. For my question i explain how i set up my lights with Switch.

I made a Switch blueprint. It work like in singleplayer. You overlap a sphere collision and then the Switch enables the Input for that Player. If you “use” the Switch, the lights toggle there visibility. The lights are a simple Array from the actor BP_Lights. If i place the Switch in the Level i can assign each light i want to that Switch. BUT: How do i manage if i have, let’s say 4 types of lights. If i want to use that lights i have to make the whole script for each light again.

Is there a way to have one Master-Blueprint and get the object of that? What’s the best way to handle multiple types of blueprints with one script?

I think there must be a way. For now all is working. But if i have to make for each object the same script, i don’t know if this is good.

For Detail:
In many Posts i saw, that the People have the Problem to get the Players Controller id. In singleplayer it is always 0. But in multiplayer i have found a way that work. Like i say with overlapping Players and enable Input. I do the following: OverlappingActor->Cast to Player->get controller->cast to controller->get controlled pawn->enable input->Use object->cast to controller->Use “Server”->cast to player->Use

This way is really complicated, but it work very well.

I hope someone could give me a tip how to handle many types of items.

Yup, there’s a way, it’s called “Object Oriented” coding.

In Unreal 4 as in many other engines / SDK it takes the form of Class and Child Class.

An element in Unreal is a class with a set of properties (components, variables, functions).
If we make an element a child class of another element, it will *inherit *its properties (it will have them all and also give you the possibility to manipulate them / add new ones).

In your case, you want to have a BP_Light then have child classes of that class.

When you create a new Blueprint Class in your project hierarchy, you can open up a dropdown menu “All classes” and search for the classes YOU created. In your case you want to create new blueprint based on your BP_Light.

It will have all components, functions and variables created in the BP_Light (but some might be hidden, you can show them using “show inherited variables”).

At that point, you can do as many child blueprints of the light as you want (for example one might be of a different color than the parent class, another might have a different blinking animation and the last one might need to be powered up).

And there are many uses to the Object Oriented method, like function overriding / super calling but that’s something you’ll need to discover on your own / search for it.

Maybe something like this:

[QUOTE=Yun-Kun;736658]
Yup, there’s a way, it’s called “Object Oriented” coding.

In Unreal 4 as in many other engines / SDK it takes the form of Class and Child Class.

An element in Unreal is a class with a set of properties (components, variables, functions).
If we make an element a child class of another element, it will *inherit *its properties (it will have them all and also give you the possibility to manipulate them / add new ones).

In your case, you want to have a BP_Light then have child classes of that class.

When you create a new Blueprint Class in your project hierarchy, you can open up a dropdown menu “All classes” and search for the classes YOU created. In your case you want to create new blueprint based on your BP_Light.

It will have all components, functions and variables created in the BP_Light (but some might be hidden, you can show them using “show inherited variables”).

At that point, you can do as many child blueprints of the light as you want (for example one might be of a different color than the parent class, another might have a different blinking animation and the last one might need to be powered up).

And there are many uses to the Object Oriented method, like function overriding / super calling but that’s something you’ll need to discover on your own / search for it.

Maybe something like this:https://youtube.com/watch?v=TU41INnZKC4[/QUOTE]

Thanks for your answer.

I know there are BP classes and i can make childs of it. But how can i Access them? I don’t get it. I have the Switch. This Switch calls over the Controller to use that light. But if i make childs i have do call that child right? Or do i think in the wrong way? All time i think like: get all actors of class-> then do what? So i have the class, but i have do get to the child of this class. And this child is actually specific, isn’t it?

E D I T:
Nevermind. I found out how i can acces them all. Shame on me!