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"

Teleporting players in Multiplayer behaving very unreliably..

I've been trying to make a multiplayer / up-to-4-player death-match style game, (tho it's a space-fighter style game, in VR).. And I've encountered an odd issue..

The players start/join/spawn into a Lobby room, into their own PlayerStarts, and then when the Host is ready, they're supposed to be Teleported out of that room, and into their own separate hanger-bays, before the actual fight-round starts.

My issue happens here, for some reason.. About 50% of the time, the teleport works as intended, when teleporting the player from the Lobby to their Hanger. And it seems to work in all other situations fine, like the normal respawning when a player dies, or quits the match. But that other 50%, of that Lobby-To-Hanger teleport, randomly fails for some reason. I haven't been able to determine much of a pattern in my own debugging, and I've tried several methods to fix this, with no luck. I've tried using several different functions, Teleport, SetLocation, SetLocationAndRotation, and tried setting the root component instead of the actor.. They all randomly fail in this scenario. I've even tried setting up a couple different types of loops, that were supposed to check if the player actually moved, and try again if they didn't, but even that didn't fix it the random failure to move.. Tho I'm not sure I did that right either.

I'm not sure if my code is doing something wrong.. The teleport function/event is set to RunOnServer reliably, and all other code I run around it seems to be working fine in debug. I've tried complicated solutions and simplified ones.. Been stuck on this for weeks, and I'm at my wits end. Starting to think this might be a bug..

Product Version: UE 4.13
Tags:
more ▼

asked Sep 27 '16 at 08:06 PM in Blueprint Scripting

avatar image

NikoKun
83 4 8 13

avatar image NikoKun Sep 29 '16 at 02:40 PM

Does anyone have any idea what might be causing this weird behavior? Here are pictures of my blueprint: This teleport fails half the time. For some reason, doing a teleport this way, triggered from a DoOnce running on Tick which checks some conditions, this fails roughly half the time for some reason. It runs BOTH things before and after the teleport call, so I KNOW it's calling that teleport function, it's just not producing results half the time, EVEN when I run a loop in various places, which checks to see if they teleported, and tries again if not. Even that doesn't work. wtf? Meanwhile this works fine. Meanwhile, doing a teleport this way seems to work perfectly fine, and I've yet to notice a Respawn Teleport fail, when it's setup this way. This is a Respawn event, that runs on Server as well.

Does anyone have any clue why this is happening? I don't know where to go from here, other than re-design my whole lobby/build/round system, to not even use that first teleport at all. But that means players won't be able to see eachother spawn in, as easily.

teleportbug.png (395.8 kB)
teleportbug2.png (280.0 kB)
avatar image NikoKun Sep 30 '16 at 03:22 AM

This just keeps getting weirder, and more frustrating.

I was trying to think of ways I could isolate this teleporting behavior, from all other parts of my scripting, in order to debug it.. and I thought I found a way: This is inside the level blueprint. So basically, what I've done this time, is have the Level Blueprint (since it wasn't doing anything at all) check all existing players, to see if their Build State activates, and if they are located in their Build Hangers, and if not, it then teleports them there.

Somehow, even THIS method produces the SAME results, of teleporting sometimes, but not always.. And the only contact this has with other parts of my game is that Build Mode bool.. Which I know IS changing, because other things are responding to it change. (My build-ui features always activate, even when it doesn't teleport, and they rely on that bool.)

Excuse me for being unprofessional but, how can this NOT work??? WTF?

teleportbug4.png (262.6 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey NikoKun,

I am not having any issue with something simple, such as:

alt text

Now, considering the complexity of your setup, I recommend that you go through it and make sure that the 50% (or so) working, isn't the teleport itself and maybe a bool or other variable sometimes not being set correctly, making it look like the teleport is what's broken.

496546_teleport.png (400.6 kB)
more ▼

answered Sep 29 '16 at 03:29 PM

avatar image

ImVawx ♦♦ STAFF
6.8k 114 18 128

avatar image NikoKun Sep 29 '16 at 03:43 PM

There's a couple reasons for the extra complexity in my script. The players spawn/join into a Lobby area/room. And then, when the host is ready he pushes a UI button which via a GameMode script updates all the player's build-states to On, and activates a couple other things. Once the player scripts detect their build-state change, it changes the visibility of some UI stuff and objects, and is supposed to move the player to the build-Hanger area.. But it doesn't do that sometimes, even tho it runs every other function around the teleport, like the visibility stuff.

However, I was originally unable to find the SetActorTransform function inside my GameMode script.. And so I just assumed that I wasn't allowed to do that in there.. If I CAN actually do that, it would simplify things a TON.. So I'll go back and try that. Thanks. Hopefully it will work, but after all I've tried, I can't get my hopes up..lol

avatar image NikoKun Sep 29 '16 at 04:32 PM

Ok so I tried switching the teleport into the GameMode script, like this: alt text But believe it or not, this STILL isn't working.. It's still failing to teleport sometimes.. And other times it works fine.

Just to clarify what I've done here, OnPostLogin I'm storing each player's reference into a variable in their own PlayerStates, for ease of use. Then On Begin Play, the player's Pawn store's it's LobbySpawn location into the PlayerState, which is then used to determine where that player's Hanger is (7800 units in front of them, behind a wall.lol) But yeah.. doing it in the GameMode didn't seem to fix it.

A bit more detail, only the Host player has a Begin Build Round button, which he clicks on, in a VR 3D interactable widget in his cockpit. This sends the signal to the GameMode, which then now does the teleport. I've tried putting delays in various places, to see if maybe something wasn't ready yet, but that didn't have any effect either.

EDIT: Next I guess I'll try using that Get All Actors of Class function, and forget about using the saved Lobby Spawn, instead just use those actors current position plus a forward.. See if that works any differently..

EDIT2: Ok, I tried detecting all the players using the GetAllActorsofClass thing, and I'm getting the SAME problem, even when using that to move the players.. ugh why..

Maybe I need to do some sort of Validation checks? I don't really know how those work.. hmm

Am I doing something wrong with the way the map is loading in maybe? Even tho there have been exceptions to this, It seems like it tends to happen mostly, when I hurry to click the StartBuild button right after opening the level/session. If I wait for a few moments then click the button, it happens less often.. But I've tried adding delays to slow the player down, by hiding the button for like 10 seconds, and that doesn't help even a tiny bit.

teleportbug3.png (311.6 kB)
avatar image NikoKun Sep 29 '16 at 08:09 PM

There's gotta be SOMETHING simple, that I'm doing wrong somewhere.. Otherwise this doesn't make ANY sense to me, this should be a relatively trivial thing to get working, but now it's halted my progress.. I've run out of alternative ways to try and get players to teleport out of the lobby consistently, even loops that check and try again don't produce a different result..

Either I'm missing some simple little thing somewhere.. Or there's a bug with 4.13 in this regard, and it'd be pretty serious.

avatar image ImVawx ♦♦ STAFF Sep 29 '16 at 08:23 PM

I am able to teleport players around in a multiplayer environment with no issue, as shown in the post above, using 4.13. With that in mind, it is not a bug with the engine.

For yours specifically, in the GameMode, you do not need it to be a server function as the GameMode is only ever on the server. Secondly, make sure that the Character/Controller that is calling the GameMode is an authority (or from a server function if a client is calling it). You also no not need to check if there is authority from the GameMode because again, its always only on the server. And lastly, can you try checking the "Teleport" check box on the Set Actor Transform node?

avatar image NikoKun Sep 29 '16 at 08:48 PM

Well, thank you for all those suggestions. I've just done all of it, and I tested each step of the way. Sadly no improvement. Players are still only teleported sometimes. The teleport checkbox didn't seem to do anything either. :(

Keep in mind, I'm not teleporting them around the map during actual gameplay, as THAT would probably work fine, and similarly, my Player-Died-Respawn teleport works perfectly fine.. But for some reason, just when moving them from a Lobby room, to a Hanger room, mostly only at the start of a session, it fails to teleport them half the time.

Sorry, I'm trying my best to clarify this stuff, in case it might help figure out what is and isn't causing this problem.. :/

One of the things I've noticed, is that this issue seems to happen the most, at the start of a multiplayer session.. If the player quickly goes from Starting to Host a session, to pressing the Starting Build Round button right after things load in, the game seemingly misses the teleport. However, If the player takes more time, and waits a bit after starting the session and giving it more time, the teleport works more often.. Although I think I've still encountered it a couple times, even after waiting a while.. Also adding a forced delay in, that disables the button for a bit after hosting, doesn't seem to help here, which is very strange.. I'm not sure this has much to do with the cause tho..

avatar image ImVawx ♦♦ STAFF Sep 29 '16 at 08:54 PM

Maybe I don't understand what you are doing.

Are you moving characters between levels? Like, LobbyLevel.map to GameLevel.map? Or, is it one map where you have a "lobby" area and a "game" area?

avatar image NikoKun Sep 29 '16 at 09:06 PM

It's all on 1 map. I have a space station floating in space. Inside the middle section is an isolated spawn Lobby room, where players connect into, and respawn into so players can't shoot dead people. And then on 4 sides of the station are Hanger Bays for players to build in.

Each player is teleported to their corresponding hanger, which is simply 7800 units out in front of said player's PlayerStart, which are already angled in the Lobby room properly for that.

For now, I also haven't been Destroying the Player's Pawns on Death, they're just teleported back to the lobby, and their health is reset. This seems to works fine..

Another bit of into, the player is basically a chair with a cockpit around it, a VR camera system mounted in it, and players build ship-parts onto the outsides of that. All seems to work fine so far.

Players are also Physics Controlled, movement/flight wise, which updates on the server, and is then sent to the clients, and that works fine. But during the Lobby and Build stages, the player's ship controls are disabled.

Although, I did not disable server-side physics at that time of teleport, as that didn't seem to be an issue, since the Respawn teleport works fine, with it enabled. If this could be a problem, I'll try it too.

avatar image ImVawx ♦♦ STAFF Sep 29 '16 at 09:13 PM

You might want to break down everything you're doing to the absolute basics. As in, have a empty character and then teleport just that. If that works as it should 100% of the time, continue to build on the functionality. I feel like your situation is having a lot going on and because of everything, it is difficult to figure out why it's not working correctly (or the way you want it to).

avatar image NikoKun Sep 29 '16 at 09:36 PM

Ok well, I guess I'll have to try debugging it like that.. some more..

I've already tried doing this teleport in so many different ways, and I've changed/improved the way my whole character functions, by a lot in the process.. But every time I think I've found the Logical cause of this issue, and fixed it.. Upon testing, it's still happening..

I guess that's my only option now, to make a simpler character and see if it can teleport properly.. So I'll get back to you on that..

Tho I'm kinda surprised that no one else has encountered something like this before on here.. :/

avatar image NikoKun Sep 30 '16 at 03:29 AM

Even this didn't work:

I was trying to think of ways I could isolate this teleporting behavior, from all other parts of my scripting, in order to debug it.. and I think I found a way: This is inside the level blueprint. So basically, what I've done this time, is have the Level Blueprint (since it wasn't doing anything at all) check all existing players, to see if their Build State activates, and if they are located in their Build Hangers, and if not, it then teleports them there.

Somehow, even THIS method produces the SAME results, of teleporting sometimes, but not always.. And the only contact this has with other parts of my game is that Build Mode bool.. Which I know IS changing, because other things are responding to it change. (My build-ui features always activate, even when it doesn't teleport, and they rely on that bool.)

avatar image ImVawx ♦♦ STAFF Sep 30 '16 at 12:52 PM

Hey NikoKun,

Just a few things from my end that I would consider changing:

  • Don't use Tick to do this. Wait for / make an event that is called to teleport.

  • Use an actual Actor for the point to spawn to and not an arbitrary point in space based on 7800 CM in front of "Lobby Spawn"

  • I don't know what BuildMode does but if it ever changes, every client after that won't teleport.

  • I have no idea why there is a check to see if Actor Location is equal to the offset location (with a tolerance of 0.0001). I don't even think its needed.

And finally, if you want, you can send me a copy of your project. You can either post it here or send me a PM on the forums. I will try to look at it.

avatar image NikoKun Sep 30 '16 at 02:40 PM

Ok, keep in mind that last post was me trying to brute-force the problem, using the Level Blueprint instead of player-pawn to do it.

The BuildMode bool is PER player state, and is turned on when the player is supposed to start building their ship, and turns off when they're done. After debugging things as much as I already have, I'm pretty sure that Bool variable IS getting turned on and off properly. As there are UI features which respond to it's state, and they always work right, even when the player isn't teleported properly.

  • As far as that Tick suggestion, it was just a quick experiment, to see what would happen. I wouldn't normally do this in the Level Blueprint, as I don't know how to properly trigger things between that and a pawn. Originally, I was calling an event to teleport, that was triggered by Do Once loops that reset eachother, so I could check/react to state changes. Not sure how I can trigger a custom event inside the LB, from somewhere else tho.

  • I'll try using a dummy actor for the teleport locations, instead of doing it in math. But why would the engine care whether a coordinate came from math or from something's position? I'll try it tho.

  • That check to see if Actor Location was =, was there to try and force the level blueprint to enforce the player's New position.. Basically, I didn't want it to try to Always teleport the player during the build stage, I only wanted it to try if they weren't where they were supposed to be. heh This still teleported the players properly, but it didn't fix the issue, which boggles my mind.

Again tho, this wasn't needed, it was just me trying to brute-force this to teleport the player, if they weren't there. I'll probably remove this experiment. lol Replacing my math with dummy-actors seems to be my next available option to test.

hmm, I guess I could consider sending my project to someone or posting it, if I really can't get this fixed myself.. Thanks for offering. I'll try some more things first.

avatar image NikoKun Sep 30 '16 at 04:05 PM

OK, So good news! It turns out, it WAS something to do with that Math. I dono why, but for some reason if I give the Set Location a constant coordinate (as in, no wiring it to anything just typed 8000x 0y 0z for the New location target), or the location of a dummy actor, THAT works! Thank you for suggesting that! I never would have considered something about the way it uses the Math, would be causing an issue like this. That seems VERY odd. heh

But yeah, I'm glad this seems to have fixed it! Again, thank you! :D

(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