Improve the none splitscreen

I am glad I could help. :slight_smile:
And don’t worry about it. I was in the same place a few month back.

[=;223700]
I am glad I could help. :slight_smile:
And don’t worry about it. I was in the same place a few month back.
[/]

I keep playing my little game and can’t believe it’s finally working. I tried to run all over the place, jumping, running towards obstacles and your solution is solid. LOVE IT :smiley:

[=;223659]
I made a small example script to illustrate what I am talking about. I am sure there are hundreds of other ways to do that and this one is most certainly not the best one but it should keep your characters within bounds.
This would be part of the event graph of your camera actor.

&stc=1

I have not tested the script and it might be necessary flip the two character references in the top left corner if the characters start switching positions on each frame.
Also the ‘divide by two’ node can obviously be merged with the clamp node but I hope doing it this way makes the ‘why’ a little bit clearer.
[/]

/slowclap :cool:

I’ve been playing with this trying to make it work for 4 players but it seems much more complicated math than what my brain can take lol
Any suggestions?

That would be more complicated, indeed. But it is definitivly possible. I have an untested idea in my head that you could try out: ( no warranties :slight_smile: )

  • Imagine the locations of your four characters simply as points in space. As a fifth point you have the camera location.
  • Now find out which of the four points is closest to your camera point.
  • Now take the forward vector of your camera and find out at which point along the vector the distance to the point found in step two is shortest and remember that point. I will call that point ‘p’
  • Now construct an imaginary plane that includes the point ‘p’ and has a normal vector that is parallel to the forward vector of the camera.
  • Now you need to compute the projection of all four points onto this plane.
  • Now you must determine the smallest rectangle that includes all four points on that plane.
  • This rectangle is the area of the level that must be shown on the screen. From this point on things should be simpler:
  • You need to compare the aspect ratio of your viewport to the ratio of the sides of the rectangle: If the aspect ratio of the rectangle is larger than the aspect ratio of the viewport, you will need the larger side of the rectangle for the next step. Otherwise you will need the shorter one.
  • From this point on you can use the script you allready have: instead of the distance vector between two actors you would use the vector determined in the previous step.

I imagine that sounds pretty confusing but I don’t believe there is a straight forward solution for this problem. :slight_smile:

WOW, It sounds very intelligent Math. I don’t even want trying this. I’m happy with the 2 players for now lol

Another way to do this btw (which we did for Eclipse), is to add a force to each pawn instead of using a hard clamp. That way you get a cool ‘spongey’ feel. Players can escape if they try hard enough, but they’ll always get forced back into the viewpoint.

[=;225021]
Another way to do this btw (which we did for Eclipse), is to add a force to each pawn instead of using a hard clamp. That way you get a cool ‘spongey’ feel. Players can escape if they try hard enough, but they’ll always get forced back into the viewpoint.
[/]

Thank you , hmm, do you have a video showing Eclipse?

Now the problem is I can’t ask the Event Tick to fire only if the player selected multiplayer mode in the mail menu. Any idea how can I fire the event based on condition?

[=;225153]
Now the problem is I can’t ask the Event Tick to fire only if the player selected multiplayer mode in the mail menu. Any idea how can I fire the event based on condition?
[/]

Event Begin Play (In Game Instance or Save Game) > Cast to Player Controller > Set Multiplayer? to true or false depending on what the Game Instance / Save Game says. Then Tick > Set Multiplayer? If false, don’t do it, if true, do the code.

[=KitatusStudios;225159]
Event Begin Play (In Game Instance or Save Game) > Cast to Player Controller > Set Multiplayer? to true or false depending on what the Game Instance / Save Game says. Then Tick > Set Multiplayer? If false, don’t do it, if true, do the code.
[/]

that’s exactly what I am trying to do but for some reason the boolean value is not saved in the slot!
Will play with Game Instance. If you know a useful tutorial please link it.

[=;225203]
that’s exactly what I am trying to do but for some reason the boolean value is not saved in the slot!
Will play with Game Instance. If you know a useful tutorial please link it.
[/]

This might help, I haven’t seen it yet but it should help: https://www…com/watch?v=K_4CWDxwufg

[=KitatusStudios;225211]
This might help, I haven’t seen it yet but it should help: https://www…com/watch?v=K_4CWDxwufg
[/]

that was exactly the one I watched 10 minutes ago. Yes it helps, thank you very much. Game Instance works just fine. The save file had a problem with the boolean not sure if it was a bug or is it the way the engine deal with memory and other stuff. the main thing is now it’s working just great :smiley:

[=;223449]
That sounds like the disable split screen feaure works as you would expect: Instead of two camera views you only get one. The video you posted shows only one camera view so switching split screen to ‘off’ would get you what you want. I think there is absolutely no way the engine could know how exactly you want the camera to behave without you telling the engine how. I cannot offer you a detailed tutorial right now but can quickly explain how I would implement something like the camera in the video:

  • I would remove the camera components from the playable characters.
  • Create an empty actor an set the actor location to the center point between both characters on each tick in the event graph.
  • Attach a camera arm component to the centered actor.
  • Attach a camera component to the camera arm.
  • Update the length of the camera arm in the ‘Tick’ event of the actor based on the distance between the two player characters. (You can use Lerp nodes to smooth the camera position changes.)

You might have to play around with the camera arm length to get a nice result but the overall method should work. If you have trouble implementing that you can write me a pm and I will try to come up with a more detailed tutorial.
[/]

Can you post a picture? Is the picture you posted the same thing?

[=Ihaveaquestionguy;262417]
Can you post a picture? Is the picture you posted the same thing?
[/]

yes, just mimic the picture and everything will magically work :smiley:

Thanks !

Never mind i found the camera actor’s blueprint. How are you accessing the characters from within the camera actor blueprint?