once the “blue slab” misses the ball, the ball gets eliminated and a new ball is created at x+2 of slab.
. Almost everything went fine but I am having problem with “re spawning”.
.
I coded such that the new ball created starts bouncing after we initiate bouncing by pressing left mouse button.( up and down arrows are used to control slab)
.
But after re spawning, I could move slab with arrow keys but ball does’nt start bouncing even after pressing mouse button.
.
I have used following 3 c# files for the project… ball.cs score.cs (its not for score…its for interaction with dead zone) realscore.cs (for scorring)
.
I have checked with debugging and found that once " void OnTriggerEnter(Collider other)" funtion in score.cs
is called, “void Update ()” function in ball.cs is never called again.
Does the ballpref (I assume it’s a prefab) has the ‘ball.cs’ script attached?
One suggestion I would like to make is instead of destroying the game object and create a new instance, why not just move ballx to the initial position?
You do not inherit from MonoBehaviour (Which I see you do)
Your script is not attached to object which is on active scene
You meet the first point, since your classes all inherit from MonoBehaviour, e.g.:
public class realscore : MonoBehaviour
The second point is, when you are in Unity Editor, the script which should run Update methods, should be attached to GameObjects which you have on your current scene/level.
The thing I see is that you are using Debug.Log(), dont use that, I didnt use C# outside of Unity engine, but I think this is console(cmd) output when you are making some native C# application.
Help! I’m not new to unity (although I’m not a pro either) and my Update() function is not running. The object is instantiated during runtime. As far as I can tell, the object and component are active and enabled. The code is something like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScriptThing: MonoBehaviour
{
//variables declared here
void Update()
{
print("Update ran.");
}
}
Any ideas for what could be the problem?
Edit: Start() runs successfully, and the code also receives function calls from UI button clicks successfully.
@useralpha I’ve got the same problem and I saw that you also use UnityEngine.UI. I’ve got my script on a UI element and it may have to do with that, though I don’t know how to get around it yet.
Hello ppl, I’m having the same problem with only one script Like Agent11196 changing to FixedUpdate() does help, but there is nothing to do with UnityEngine.UI since in my case I’m not using it, anyways I reposted this threde here > Unity 2020.3.5f1 Not Calling Update - Unity Forum since this one is from 2015 cheers.