Hello,
I wanted to ask if there is anyway to teleport a UCC character through DSU to a specific location. UCC does that for teleporters and for respawning a character. I am trying to use this for several purposes, one of which is to teleport a character to a specific point before scene change, as the UCC Saver's save position keeps the character at their last location, but I may have a different location for them to spawn at.
I have checked the current integration page, and did not see any functions related to this. If it is not possible, what is the best way to call any UCC functions through Lua or Execute actions of DSU.
On a side note, I am also trying to find a way to disable and enable a character ability through DSU as well, if it is at all possible.
I appreciate any pointers.
UCC Teleport Through Lua
Re: UCC Teleport Through Lua
Hi,
If this is for the player character (i.e., tagged 'Player'), and if you can change scenes through the Dialogue System (e.g., using LoadLevel() or SaveSystem.LoadScene()/SaveSystemMethods.LoadScene), you can specify a spawnpoint. If you're using the UCC integration in version 2.1.0 or higher, the UCC Saver will observe that spawnpoint rather than moving the player to the last saved position.
There isn't a teleport Lua function.pegassy wrote: ↑Sat Dec 29, 2018 2:40 pmI wanted to ask if there is anyway to teleport a UCC character through DSU to a specific location. UCC does that for teleporters and for respawning a character. I am trying to use this for several purposes, one of which is to teleport a character to a specific point before scene change, as the UCC Saver's save position keeps the character at their last location, but I may have a different location for them to spawn at.
If this is for the player character (i.e., tagged 'Player'), and if you can change scenes through the Dialogue System (e.g., using LoadLevel() or SaveSystem.LoadScene()/SaveSystemMethods.LoadScene), you can specify a spawnpoint. If you're using the UCC integration in version 2.1.0 or higher, the UCC Saver will observe that spawnpoint rather than moving the player to the last saved position.
You'd need to write a custom Lua function or sequencer command.pegassy wrote: ↑Sat Dec 29, 2018 2:40 pmI have checked the current integration page, and did not see any functions related to this. If it is not possible, what is the best way to call any UCC functions through Lua or Execute actions of DSU.
On a side note, I am also trying to find a way to disable and enable a character ability through DSU as well, if it is at all possible.
Re: UCC Teleport Through Lua
Thank you Tony.
So just to get what UCC saver does correctly: If my character starts the level at let's say (0,0,0) and ends the level at (-20,-50,0), and if load another level while UCC Saver is on the character and location saver is ticked, then the character will start that level at (0,0,0)? And if the character went to another level and came back at a different position (lets say (10,10,0)) will that new position be considered as the spawn point, or will it be the initial one? Or does it look for the UCC spawn point scripted objects?
So just to get what UCC saver does correctly: If my character starts the level at let's say (0,0,0) and ends the level at (-20,-50,0), and if load another level while UCC Saver is on the character and location saver is ticked, then the character will start that level at (0,0,0)? And if the character went to another level and came back at a different position (lets say (10,10,0)) will that new position be considered as the spawn point, or will it be the initial one? Or does it look for the UCC spawn point scripted objects?
Re: UCC Teleport Through Lua
My bad. I read the post again now and understand how it works. I missed that you can designate a spawnpoint parameter in LoadLevel() function. Thank you so much.
Re: UCC Teleport Through Lua
I have been working on using the LoadScene(SceneName, SpawnPoint) function in multiple scenarios now, and it seems to be working really good.
One small glitch is though that after a level that he had previously been on is loaded back (for example, if you started at level A, and then went to level B, and came back to level A again) the character will show up on his earlier start position in that level for 1-2 seconds (or more if you are loading in the editor) and will teleport to the new spawn point designated in the LoadScene function. It is not a huge deal while prototyping, but for a polished game it will definitely impact the smoothness.
I am wondering if that is being caused by using both UCCsaver and (SceneName, Spawn Point) at the same time, which is actually slightly confusing for me. So, UCCsaver has a Save Position function, which should make the character spawn at the last position that he was at before a scene change, is that correct? I saw this work earlier when I went from A->B->A , the character would show up at the last position at A, without using a spawn point. And somehow it started not working, and then I started using the loadscene(level, spawn position). So I am thinking I should be doing something wrong using both, and that may be causing the temporary wrong spawn position during level change.
One small glitch is though that after a level that he had previously been on is loaded back (for example, if you started at level A, and then went to level B, and came back to level A again) the character will show up on his earlier start position in that level for 1-2 seconds (or more if you are loading in the editor) and will teleport to the new spawn point designated in the LoadScene function. It is not a huge deal while prototyping, but for a polished game it will definitely impact the smoothness.
I am wondering if that is being caused by using both UCCsaver and (SceneName, Spawn Point) at the same time, which is actually slightly confusing for me. So, UCCsaver has a Save Position function, which should make the character spawn at the last position that he was at before a scene change, is that correct? I saw this work earlier when I went from A->B->A , the character would show up at the last position at A, without using a spawn point. And somehow it started not working, and then I started using the loadscene(level, spawn position). So I am thinking I should be doing something wrong using both, and that may be causing the temporary wrong spawn position during level change.
Re: UCC Teleport Through Lua
Hi,
It sounds like you may be doing it right. For UCC, spawnpoints depend on the UCCSaver component.
It may wait a few frames before moving the player into position, but it shouldn't wait 1-2 seconds. This is how it works:
It sounds like you may be doing it right. For UCC, spawnpoints depend on the UCCSaver component.
It may wait a few frames before moving the player into position, but it shouldn't wait 1-2 seconds. This is how it works:
- You use the LoadLevel() sequencer command or call SaveSystem.LoadScene, specifying a spawnpoint in level A. The Dialogue System's Save System makes a note of the name of the spawnpoint.
- The Save System tells Savers in the current level (level B) to record their states, such as the player's current health, ammo, etc., in UCCSaver, and the states of any other Saver components in level B.
- Optional: If the Save System has a Scene Transition Manager, it might load a loading scene or play an animation such as fading the screen to black.
- The Save System loads level A.
- Optional: If the Save System has a Scene Transition Manager, it might play an animation such as fading the screen back in from black.
- The Save System waits a number of frames specified by Frames To Wait Before Apply Data. This is usually 1, which gives other scripts a chance to run their Start methods to initialize themselves.
- If the Save System had noted the name of a spawnpoint, it finds the GameObject with that name.
- The Save System tells Savers in level A to apply recorded data to their states. The UCCSaver component will apply the player's health, ammo, etc. It will also check if the the Save System has found a spawnpoint GameObject. If so, it will move the player to the spawnpoint. Otherwise, it will apply the saved position.
Re: UCC Teleport Through Lua
Thank you so much for taking the time to explain.
Just to double check that I understand correctly, if I am not specifying any spawn points during load, will UCC saver still save the last position of the player and spawn him at that point when I move from B to A again? i recall this used to work and then somehow I broke it, and hence using the spawn points.
Just to double check that I understand correctly, if I am not specifying any spawn points during load, will UCC saver still save the last position of the player and spawn him at that point when I move from B to A again? i recall this used to work and then somehow I broke it, and hence using the spawn points.
Re: UCC Teleport Through Lua
Currently, if you don't specify a spawnpoint it really only works well when you save a game and load it. In the next update, the UCC Saver component will remember the position in each scene. So when you leave scene A, it will record your position in scene A. When you leave scene B, it will record your position in scene B. If you then go to scene C and then back to scene A, all without specifying spawnpoints, it will remember your previous position in scene A. Currently it doesn't do this.
It'll be a nice feature to add, but in practice I think you're really only going to load the saved position when loading a saved game. When you're traveling across scenes, you're almost certainly going to use spawnpoints.
It'll be a nice feature to add, but in practice I think you're really only going to load the saved position when loading a saved game. When you're traveling across scenes, you're almost certainly going to use spawnpoints.
Re: UCC Teleport Through Lua
That sounds great. Since character leaves a scene from an exit and usually comes back through the same exit, position saving should work fine. But given that the spawn points also designate the transform when spawned back, it is helpful to turn around a character that is coming back from a door, instead of going into it.