- Home /
How can I reset a sequence or order using Integers?
Hello!
I am trying to reset a sequence to 1 on a mouse click when the sequence hits 3. The issue I'm having is, it only cycles 1 and 2 and when I click the mouse on the object on two, it resets to 1 rather than going to 3 first.
I'm using increments to increase the sequence on click. It either never makes it to 3 or it skips it and resets after clicking on 2.
here's a small snippet for how it resets.
if(hit.transform.tag =="B1Tag" && B1 == 3 ) { B1 = 1; }
Hit is the mouse click/input.
any help would be appreciated
I'm using raycast to tell the mouse to check raycast based on tag to increment ++. I'm using colors for representing 1, 2, and 3. The issue I am facing is, once it gets to three, I want to , onclick of that object, to reset to 1. The issue I'm facing is, once It's incremented to 2 and I click, it goes to 1 rather than going to 3(green). I want it to go to 3 and then when I click (because it's set to 3) it will set itself to 1 again, and repeat.
This is an example of the code for increment:
void CheckRaycast() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit;
if (Physics.Raycast(ray, out hit, 1000f))
{
if (hit.transform != null)
{
if (hit.transform.tag == "B1Tag")
{
B1++; }
the reset syntax is:
if(hit.transform.tag =="B1Tag" && B1 == 3 ) { B1 = 1; }
it's never making it to 3 and just resets before it on click it seems. so it looks like it just cycles 1 and 2.
Answer by Happy-Zomby · Nov 23, 2020 at 02:09 PM
Maybe if(hit.transform.tag =="B1Tag" && B1 > 3 ) { B1 = 1; }
Your answer
![](https://koobas.hobune.stream/wayback/20220613020335im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
My camera script is having a lot of problems..... 2 Answers
Script Help -- OnCollisionEnter2D 1 Answer
Hello, i am new to Unity and would like help making a player mechanic. 0 Answers
How do I build up speed while wallrunning? 1 Answer
How Do I rotate a Object Based On the player's location? 1 Answer