Question by
Keergen · Feb 15, 2019 at 09:44 PM ·
c#scripting problemgameobjectsslider
Swapping characters breaks controls
I have a simple character swap er that sets your selection from the store at the start of the round. problem is when it swaps to a character it no longer takes values from other scripts. such as the speed slider.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class charicterSelecter : MonoBehaviour {
// Use this for initialization
void Start () {
PlayerPrefs.SetInt("Charicter", PlayerPrefs.GetInt("Charicter"));
PlayerPrefs.SetInt("Check1", 0);
if (PlayerPrefs.GetInt("Charicter") == 0)
{
Werewolf.SetActive(false);
Zombie.SetActive(true);
Pirate.SetActive(false);
Knight.SetActive(false);
Ninja.SetActive(false);
Vampire.SetActive(false);
PlayerPrefs.SetInt("Check1", 1);
}
if (PlayerPrefs.GetInt("Charicter") == 1)
{
Werewolf.SetActive(false);
Zombie.SetActive(false);
Pirate.SetActive(false);
Knight.SetActive(true);
Ninja.SetActive(false);
Vampire.SetActive(false);
PlayerPrefs.SetInt("Check1",1);
}
}
public GameObject Zombie;
public GameObject Pirate;
public GameObject Knight;
public GameObject Ninja;
public GameObject Werewolf;
public GameObject Vampire;
// Update is called once per frame
void Update () {
PlayerPrefs.SetInt("Charicter", PlayerPrefs.GetInt("Charicter"));
}
public void OnZombie() {
PlayerPrefs.SetInt("Charicter",0);
}
}
Comment
Your answer
Follow this Question
Related Questions
Slider problem 1 Answer
Deleting random objects in started project 0 Answers
Adjust the size of the object within a parent container 0 Answers
I need help fixing my movement/jetpack script, it involves a slider. 0 Answers
How to create a child object inside the parent (script) and assign independent variables? 0 Answers