Update() and FixedUpdate() not running on C# scripts
For some reason on all my scripts only two method is running from Update or FixedUpdate The Scripts are all attached and enabled.
I have tried a Debug.Log from both FixedUpdate and Update and neither work.
This is my controlSys script I am trying to run getMousePos() to run but it is refusing to do anything. A print statement there also does nothing.
I'm not getting any errors or anything.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using nsVillage;
public class controlSys : MonoBehaviour
{
public Camera cam;
public Ray mousePosRay;
public RaycastHit mousePosHit;
void Start(){
}
void Update(){
if(getMousePos() != null){
Debug.Log("Debug");
}
}
void FixedUpdate(){
}
public Transform getMousePos(){
mousePosRay = cam.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(mousePosRay, out mousePosHit, 100f)){
return mousePosHit.transform;
};
return null;
}
}
I have also tried moving getMousePos to my EventSys script with no luck but Time() works in FixedUpdate() the Debug.Log in Update() doesn't
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EventSys : MonoBehaviour
{
//TIME
public bool paused = false;
public int gameSpeed;
public int totalTime;
public int curTime;
public int curSec;
public int secsInMins = 60;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
Debug.Log("Test");
}
void FixedUpdate(){
Time();
}
public void Time(){
if(!paused){
curSec = curSec + 1;
if(curSec >= secsInMins / gameSpeed){
curSec = 0;
curTime = curTime + 1;
totalTime = totalTime + 1;
}
}
}
}
Your answer
Follow this Question
Related Questions
FixedUpdate and Update not working in script 0 Answers
How do i put "Wasted!" after respawn? 0 Answers
"The associated script cannot be loaded." 0 Answers
How can i make my spaceship to land automatic on the Base ? 1 Answer
Why when i color 4 walls of a grid 10x10 it's coloring 10,9,9,8 and not 10,10,10,10 ? 0 Answers