How do I put it so that in my videogame I can change my character? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do I put it so that in my videogame I can change my character?

6th May 2018, 8:11 PM
Daniel Villa
Daniel Villa - avatar
11 Answers
+ 1
I am going to assume that each character has a different behaviour. This is how I would do it: 1. Create an empty game object which is going to control the rules of the game. A script is going to be attached to this game object and you need to make sure it does not destroy when loading different scenes by writing: DontDestroyOnLoad(gameObject) in the awake method. You also need to make sure that just one instance of this game object is created by using a software pattern design known as singleton. 2. Design the menu where the user is going to select which player they will use. 3. Implement a button in the previous canvas with an action from the script attached to the game object created in step1. 4. The action is actually a method which will check which player is going to be selected. And as this object does not destroy on load, then when you load the scene where you actually play, you can instantiate the correct character. 5.Also make sure you have an abstract class where the behaviours and attributes of all players are defined. And then just create subclasses for each character. This last step is not mandatory but it is good pracctice. I hope I made myself understood. Have fun
10th May 2018, 2:50 PM
Jhon
Jhon - avatar
+ 2
Daniel Villa and if you need tutorial, I have a channel suggestion. It is Redfoc Tutorial
25th May 2018, 2:53 PM
Hiro
Hiro - avatar
+ 1
Daniel Villa u can try Construct 2, you can make awesome 2d Game with it.
25th May 2018, 1:19 PM
Hiro
Hiro - avatar
+ 1
Good luck
25th May 2018, 4:30 PM
Hiro
Hiro - avatar
0
are you using a certain game engine like unity or cryengine?
10th May 2018, 1:27 AM
Jhon
Jhon - avatar
0
Unity (and visual studio for project C#). (characters in 2D)
10th May 2018, 4:37 AM
Daniel Villa
Daniel Villa - avatar
0
if by changing character you mean being able to select which player will be playable, then you could have several player prefabs, And with a script you could instantiate the one that was selected. On the other hand, if by changing character you mean being able to swap between characteres at run time, then it would be a little bit complicated, but can be achieved through a script that enables one gameobjet and disables another one. Be more explicit with what you want to do, and I could help you better
10th May 2018, 6:47 AM
Jhon
Jhon - avatar
0
For example, in the Fornite you go to a menu of character selection where you can buy or choose a character to play, like that menu so that in my video game you can choose different characters to play (characters in 2D)
10th May 2018, 2:32 PM
Daniel Villa
Daniel Villa - avatar
0
Thank you very much. I do not understand it very much because I just started alone without being taught since I can not go to a course because of my age (in summer I'll try to go to one, in 2 months), I'll see some video on YouTube, but thank you very much
10th May 2018, 3:54 PM
Daniel Villa
Daniel Villa - avatar
0
ok thanks
25th May 2018, 1:56 PM
Daniel Villa
Daniel Villa - avatar
0
ok
25th May 2018, 3:02 PM
Daniel Villa
Daniel Villa - avatar