Character Creation help needed

Updated on December 16, 2016 in [A] Unity Scripting
Share on Facebook0Tweet about this on Twitter0Share on Google+0Share on Reddit0
5 on December 15, 2016

Hi all,

At the moment i am working on a character creation code and i need a litle push in the back how to get things done. I found a script on youtube to select a model which you like to use, but nothing about how to export the model it to the game. The script i have is all below.

What do i have now?
Menu scene > Character creation (class selection)  Once you click on a picture, the model changes (gameobject > Capsule).

What do i want :)
Menu Scene > Character creation (class selection) > save all made selections and Begin the game. 

Different classis show a different kind of capsule, which i will replace later with models. But question is how do i save the made changed while you push start the game, and how you export the right model on the player in the next scene. its not clear how some ‘creation settings’ getting saved and exported as models/settings to the next scene character.

Hopefully somebody can give a beginner a push in the back :) Many thanks! 

using UnityEngine;

using System.Collections;

using System.Collections.Generic;
public class CharacterSelection : MonoBehaviour {
private System.Collections.Generic.List<GameObject> Models;

private int ClassSelection = 0;
private void Start()

{

Models = new System.Collections.Generic.List<GameObject>();

foreach(Transform t in transform)

{

Models.Add(t.gameObject);

t.gameObject.SetActive(false);

}

}
public void SelectClass (int Index)

{

if (Index == ClassSelection)

return;
if (Index < 0 || Index >= Models.Count)

return;
Models[ClassSelection].SetActive(false);

ClassSelection = Index;

Models[ClassSelection].SetActive(true);

}

}

  • Liked by
Reply
1 on December 15, 2016

This is ingame right?
So then the question is:
What do you want to save, and what for?

on December 16, 2016

Goodmorning,

Thank you for your reply, It works like the following

 

Scene 1

Menu (canvas)

You go to to the next canvas

Character creation (canvas, + gameobject>model)

 

When you click on pictures of the classes – Warrior, archer for example, than the model changes. In the future I want to make it also that you can customize armor colors etc and armor pieces, but that’s a different subject.

 

The question is: When the player select the model, en push ‘start game’  he will get in scene 2, with the chosen player model. How do I put a character in scene 2, loading the model which is chosen in scene 1. I think with a sort of save it should world, but please be open minded what the best way is to create this. I just need a push in the right direction.

Thank you! 

Show more replies
  • Liked by
Reply
Cancel
1 on December 16, 2016

So you have 3 options, and all will work.
1. Use DontDestroyOnLoad
2. Use Playerprefs
3. Use a serializer

I’m going to let you do the research ?

on December 16, 2016

Hahaha that is very usefull :) Thanks i will find more information about this.

Show more replies
  • Liked by
Reply
Cancel
0 on December 16, 2016

Thats a very small push in the back, but usefull thank you very much for your replies Dion! 

 

  • Liked by
Reply
Cancel