|
Post by zouther on Apr 5, 2020 2:16:32 GMT
Hey, I saw some simillar threads here, but none of the answers seams working for me. I made a script that change the character controler to another character, and the player can switch between these two characters. However, I can't figure it out how to change the camera's target between these characters. The camera switch only once, without any code for the camera, just enabling/desabling some components from the characters. Once is switched, the camera doesn't switch to the first character again. So, I tried to use the method SetMainTarget(character) or even the vEventWithDelay to switch the camera's target, but none of these worked. Please help me ;) if (switchCharacter.GetButtonDown() && !controlPokemon) { TPCameraScript.SetMainTarget(trainerPlayer); } if (switchCharacter.GetButtonDown() && controlPokemon) {
TPCameraScript.SetMainTarget(activePokemon);
}
|
|
|
Post by xianno on Apr 5, 2020 12:33:22 GMT
If you want to switch between two characters you have multiple solutions. I advise you to use the event system for this.
You can create an Event List that Change the MainTarget of the vThirdPersonCamera if you want your two characters to stay in the scene. You can simply "SetActive false" the first character, vThirdPersonCamera will search for the second player if the first is not on the scene. Finally you can use a second camera, if for example you are using a car or a bike. When triggering the switch, make the vCamera to be "SetActive false", and your camera on "SetActive true" it will automaticly switch on the second camera you created. With this way to do, you will easily able to trigger the switch on the first character, and then the contrary on the second.
If you don't want to use the event system, you can use SetMainTarget for vThirdPersonCamera or all the SetActive like in your script. It might work if used properly! Try creating a checking bool maybe, and put your script on the void update.
By the way, make sure you had not checked "Instantiate Character", if you change scene with multiple character it might mess up. I advise you to put manually your characters on each scene, prefabs will update while playing don't worry.
After that, you might need some others event entries. Like SetLockAllInput, SetLockCameraInput etc... Don't hesitate to ask here if you miss some script to lock/unlock while switching.
Hope it helps o/
|
|
|
Post by zouther on Apr 5, 2020 17:34:22 GMT
Thank you, that really helped me. I ended up using a second camera as you said. One for each character and activating or deactivating them when I switch between the characters. I wanted to share one camera between the characters at first, but using a second camera was the only way that worked for me. I also modified the camera script to not look for a new target on update, cause that was messing with my code, and was not switching the camera back to the first character. Now it's working fine, thank you
|
|
|
Post by nmezero776 on Jul 30, 2020 4:28:05 GMT
|
|