Question by
SteamPunk_Devil · May 11, 2019 at 08:19 PM ·
c#scripting problemupdatefixedupdate
FixedUpdate and Update not working in script
For some reason FixedUpdate and Update aren't working for my scripts, some methods work but others don't, Debug.Log isn't working.
This is my controlSys script I am trying to tell if getMousePos returns null or not. Nothing is printed. i have tried putting a Debug.Log statement in Update but that did not work.
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");
}else{
Debug.Log("Bing");
}
}
void FixedUpdate(){
}
public Transform getMousePos(){
mousePosRay = cam.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(mousePosRay, out mousePosHit, 100f)){
return mousePosHit.transform;
}else{
return null;
}
}
}
This is my eventSys script. Time in FixedUpdate works but 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;
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Update() and FixedUpdate() not running on C# scripts 0 Answers
Why does FixedUpdate work when Update() doesn't? 2 Answers
Start() and Update() execution issue 6 Answers
Vector3.Lerp in update, how stop? 1 Answer
Need help with my code 0 Answers