Character change run time ( Switch character ) ( UCC + AC )

Hello sir,

I have used the adventure creator package with UCC ( for character ). In that, I want to change ( switch between 13 -14 ) character runtime from a script. Like, I want to add character selection in my game. Can you please help with that like I have to change the character reference of the main camera etc. Also, When I change the character that time I disabled player and also disable it's character " UltimateCharacterLocomotion " object.

Can you please let me know about the solution in detail?

I am using v1.67.5 version of adventure creator and using 2.1.4 of UCC.

Thank you :)
 
I didn't create the Adventure Creator integration so unforutnately I'm not too familiar with it. To change characters though you just need to set the new camera reference and then disable the old character input with the AllowInput event:


A good example of switching characters is within the demo scene when you ride the horse - this switches to the horse character.
 
Hello sir,

==> I need features for tab key like when the user press tab key then move to UI mode and if a user in UI mode then moves to the game. When a user in UI mode then player did not display and also don't move the camera and not doing any operation on a player. When user in-game mode then displays character again and with all features. So, for that, I have a disabled character locomotion. I am sharing that code screenshot with you. You can check it.
==> Now, a user in UI mode then clicks on a particular character that time I will change character reference and all and again when the user press tab key then displays new character with all its features.
==> I have applied your solution but it does not work for me. Can you please help me with these scenarios.

Thanks.
 

Attachments

  • 2019-11-23_15-20-20.png
    2019-11-23_15-20-20.png
    32.9 KB · Views: 22
Hello sir,

When I change the character that time cameras reference not set and then I again press tab key that time it's giving me an error. I will give you in detail screenshot of an error and my code image.

Thanks.
 
Hello sir,


I have solved that error. I have changed my code sequence and add some line in the code based on my code or my requirements.

Thanks for the help :)
 
I didn't create the Adventure Creator integration so unforutnately I'm not too familiar with it. To change characters though you just need to set the new camera reference and then disable the old character input with the AllowInput event:
Hi @Justin I'm trying to implement this by spawning in a new character prefab. I've tried a bunch of different combinations of things, but the closest thing I can get is:

- Destroy Old Character and MainCamera
- Instantiate New Character and MainCamera prefabs

Result is though First Person arms don't work and Character can't use/equip weapons,though they show in their holstered positions.

Whether I assign the new Character to Camera Controller doesn't seem to fix, as it seems to pick this up auto anyway.

I don't understand the AllowInput thing - but would that fix the weapons not being equipped/change to AND first person arms?

BTW I'm after the simplest most effective way to switch to another Character so players can choose their 'class' which will simply be a preset prefab I create and set the loadout and model of. Either by instantiation or activation of the object, can you suggest simplest method for me to use?

If I can do without destroying the Camera that would be most ideal as I feel that's half the battle, but I can't ever get the Camera/Controller to switch at runtime to another character whether I destroy the Old one or not.
 
I should mention this Destroy/Instantiate method works fine on normal Characters, it only breaks when I add the PUN components to the Characters....
 
You definitely shouldn't need to destroy the camera. It should be enough to instantiate your new character object, disable/destroy the old one, then re-assign the reference in the CameraController.
 
@Andrew yep I just managed to achieve that minutes ago without destroying the Camera, only seems to work if everything is PUN or Not PUN, anything mixed doesn't seem to work.

Looking in to how to transfer ownership, I'm not great with how the syncing stuff works yet.
 
Top