Question by
SirDogey · Mar 07, 2017 at 12:23 PM ·
unity 5scripting problemunity5scriptableobject
Having Trouble Disabling Script Components.
In my Script Below i want to disable the Character Controller Script on my player. The Script Name is First Person Controller. For me it looks like i cant disable it with C# Script. Script Below.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Health : MonoBehaviour {
public Transform CorpseSpawnPoint;
public GameObject Prefab;
public int health = 100;
public int maxhealth = 100;
private bool DeathSEQDone;
private CharacterController FPSController;
// Use this for initialization
void Start () {
health = 100;
maxhealth = 100;
DeathSEQDone = false;
FPSController = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update ()
{
if (DeathSEQDone == false) {
if (health <= 0) {
Debug.Log ("Ded");
Instantiate (Prefab, CorpseSpawnPoint.position, CorpseSpawnPoint.rotation);
FPSController.enabled = false;
DeathSEQDone = true;
}
}
}
}
Comment
CharacterController is usually a component, not a script. I can see that your code is setting FPSController.enabled to false, which disables the component. Since you did it but still said you can't I don't understand what the problem is.
Answer by SirDogey · Mar 09, 2017 at 09:10 PM
For Me there is a Script Component And it looks like it disables the mouse moving the camera and all other controls on the character.