Prevent object from spawning at a spawn point twice in a row?
I have a set of spawn points and an object that I want to spawn from a random spawn point every second. I've used the InvokeRepeating function to make this work. But now, I want to modify the code a...
View ArticleHOW TO INSTANTIATE IMAGE INSIDE CANVAS?
void start(){ InvokeRepeating ("starta",2, 2); } void starta(){ float x = Random.Range(-220f, 126f); Vector3 da = new Vector3 (x,0,0); GameObject s=Instantiate...
View ArticleInvoke Ball Obstacle based on Score
In the beginning of my game there is one instantiated bouncing ball which works great. As the player earns points up to 3 balls may be present on the screen at one time. I have three separate ball...
View ArticleCoroutine in place of InvokeRepeating in need of start at time parameter
IEnumerator SendSpriteForward(int no, Coroutine n,int prevhighestorderInlayer) { while (true) { StopCoroutine (n); for (int i = 0; i < gameObjectsContainer.transform.childCount; i++) {...
View ArticleIncrease speed every 5 seconds
Why would this not work? public static float speed = -5f; public Vector2 obstacleVelocity = new Vector2(0.0f, speed); public Rigidbody2D rb; // Use this for initialization void Start() {...
View Articleif and invoke repeating in start...
This is my obstacle spawning code: public GameObject Obstacles; float gameTime; void Start() { gameTime = Time.timeSinceLevelLoad; InvokeRepeating("CreateObstacle", 1f, 1.25f); } void Update() { } void...
View ArticleMy script keeps crashing my Unity Editor Client. Please help
So I created this script recently to spawn a "enemyPrefab" every x seconds. But when the function is called on my Unity client just crashes and I have to open up Task Manager and manually End Task it...
View ArticleDisplaying C# Int Value to GUI
Hey all, I'm starting a new project and I'm trying to create a date function where every seconds adds another day. So far, my code is: using UnityEngine; using System.Collections; using UnityEngine.UI;...
View ArticleInvokeRepeating() not working.
I am trying to fire bullets at a rate determined by the weaponFireRate variable, but no matter what I do it will always fire one bullet per seconds. Here is the code: public int health; public int...
View ArticleDecreasing a value over time, called by InvokeRepeating
I'm attempting to create an effect in my game in which two discreet spot lights lower and raise their intensity every so often to give the impression that the player is actually travelling through...
View ArticleWhy aren't Coroutines working for me?
Hi, I was originally using InvokeRepeating for my enemies to spawn and it is fine if they spawn at a continuous rate but I want them to spawn faster and faster as the game goes on but since...
View ArticleGetting Updates from website
Im calling Functions on my mindstorms device running a webserver. it listens to numbers im sending e.g. 200 or 900 and drives a certain way. There is also a "motorstatus" url where the current motor...
View ArticlePause between user mouse clicks
I'm trying to make a grid turn based game and I want the user to be able to click on the grid, then have a pause function that does not let them click anywhere for 2 seconds or so then after this...
View Articleinvoke method attack.decreaseTimeRemaining couldn't be called
So the scene picks a random image of four, at which point I want a count down to start that is waiting for user input, if the countdown hits 0 the user dies if the correct input is pressed then they...
View ArticleRaycast ignoring InvokeRepeating intervals
Hi, so i posted a question to the default answers page but it's been under moderation for 2 days now so was advised to post my question here instead. I'm fairly new to Unity and coding so bear with me...
View ArticleRaycast ignoring InvokeRepeating intervals
Hi, so i'm fairly new to Unity and coding and am doing a project for college. Essentially I have 2 separate codes; the first is for the player to shoot when i hold down the "Fire1" key which works...
View ArticleIssue with starting/canceling invokes
Im having an issue with canceling/starting invokes in my update. I have a time "frenzyTimer" which sets a bool in another class in which will state what type of invoke should be running. The start...
View Articlemultiply Score on Collision not working? check my code plz
So what I'm trying to do here is when the player collide By " x2" object the score gets update +2 instead of +1 , I tried a lot of codes and I can't get anything to work, maybe its easy and I miss...
View ArticleCan I increase gravity / fallspeed of instantiated prefabs over time?
Hello! I am working on a 2D color matching / catch game and I am trying to increase the gravity of my instantiated objects so the longer the game goes on, the faster they fall. Here is the code I am...
View ArticleHow to cancel an Invoke from another script,How to Cancel an invoke from...
So basically I'm trying to cancel an InvokeRepeating call from another script using this code: void OnTriggerExit(Collider otherCollider) { if (otherCollider.tag == "Player") { CancelInvoke...
View Article