script does not disable
I wanted to stop two of my scripts when I enterd a trigger. One of the got disabled but the other one didn't. This is the one that did not get disable:
using System.Collections; using UnityEngine; using UnityEngine.UI; using System.Collections.Generic;
public class Timer : MonoBehaviour { public Text timerTxt; public float startTime;
// Use this for initialization
void Start () {
startTime = Time.time;
}
// Update is called once per frame
void Update () {
float t = Time.time - startTime;
string minutes = ((int)t / 60).ToString ();
string seconds = (t % 60).ToString();
timerTxt.text = minutes + seconds;
}
}
The one that did:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour { public Rigidbody rB; public float movementSpeed; public float turnSpeed; public float brakeSpeed; // Use this for initialization void Start () {
}
// Update is called once per frame
void FixedUpdate () {
Movement ();
}
public void Movement()
{
rB.AddRelativeForce (Vector3.right * movementSpeed);
if (Input.GetKey("s"))
{
rB.AddRelativeForce(Vector3.left * brakeSpeed);
}
if (Input.GetKey ("d")) {
rB.AddRelativeForce (Vector3.back * turnSpeed);
}
if (Input.GetKey ("a")) {
rB.AddRelativeForce (Vector3.forward * turnSpeed);
}
if (Input.GetKey("s"))
{
turnSpeed = 15f;
}
}
}
I also filled in all the objects etc.
Your answer
Follow this Question
Related Questions
how do I trigger a different game object outside a script? 0 Answers
Trigger enabling component works in one statement but not another? 1 Answer
Trigger events with bullets 0 Answers
How can i activate a script on a character when entering in a trigger zone ? 1 Answer
Trouble disabling and enabling script via another script 2 Answers