What have I done! Bugs in first program? Maybe it’s modem IRQ of 32bit drivers problem? haha
But realy!! My program runs, once it loop - back to begining does not react on pressing Enter key. Maybe I wroted first virus? hahaha
Here’s source. Please help. Anyone.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberWizard : MonoBehaviour {
int max;
int min;
int guess;
// Use this for initialization
void Start ()
{
StartGame();
}
void StartGame()
{
max = 1000;
min = 1;
guess = 500;
Debug.Log("Welcome to Number Wizard!");
Debug.Log("Pick a number!");
Debug.Log("It can be in range between : " + min + " and " + max);
Debug.Log(" ");
Debug.Log("Your number is lower or highter than: " + guess);
Debug.Log("Up = highter , down = lower , enter = this is right number");
max = max + 1;
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.UpArrow))
{
min = guess;
NextGuess();
}
else if(Input.GetKeyDown(KeyCode.DownArrow))
{
max = guess;
NextGuess();
}
else if(Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("TARGET DESTROYED. RETURN TO BASE. GAME OVER");
StartGame();
}
}
void NextGuess()
{
guess = (max + min) / 2;
Debug.Log("Your number is lower or highter than: " + guess);
}
}
I have the same thing happening. I figure it may just be because the console isn’t exactly meant to be used like this, once it goes through the display it doesnt re display things at the bottom, it merely adds a count on to how many times the function has been used or acted out, so there fore its not going to start fresh… I am new and really unsure. figured maybe if I say something even if wrong it may get someone who knows exactly whats going on to pipe up…
Do you happen to have Collapse enable on the console? If so, this groups all the messages together which are the same, so if you want to see the messages in running order, so to speak, you need to turn this back off.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberWizard : MonoBehaviour
{
int max;
int min;
int guess;
// Use this for initialization
void Start()
{
StartGame();
}
void StartGame()
{
max = 1000;
min = 1;
guess = (min + max) / 2;
Debug.Log("Imagine! The Fantastic Number Wizard WILL guess your number");
Debug.Log("Pick a Number, any number...");
Debug.Log("Okay not any number...");
Debug.Log("The highest is: " + max);
Debug.Log("The lowest is: " + min);
Debug.Log("Tell Me if your number is higher or lower than " + guess);
Debug.Log("Push up if it's Higher, Push down if it's Lower, Push Enter if I am got the number");
max = max + 1;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
{
Debug.Log("Ah, aiming for the stars");
min = guess;
NextGuess();
}
else if (Input.GetKeyDown(KeyCode.DownArrow))
{
Debug.Log("I see you think less of me");
max = guess;
NextGuess();
}
else if (Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("Your number was " + guess);
Debug.Log("Hah,I knew it");
StartGame();
}
}
void NextGuess()
{
guess = (max + min) / 2;
Debug.Log("Is it higher or lower than... " + guess);
}
}
Do I have three frames happening… Just this noobs guess… I am not understanding why… maybe if i take the start over to a new button assigned i can see if it will do this with the return function… …edit_checked on it a couple times, it does start the game over three times here as well…
GetKeyDown should respond as true in the first frame in which the button press occurs.
Can you take a screenshot with your Main Camera GameObject selected in the Hierarchy, but with the Inspector on show on the right-hand side, as opposed to the Services tab.
Can you take a screenshot of that and pop it up please, note, if you have a lot of components and it won’t all fit in the screenshot, scroll down, it’ll be the ones at the bottom I am more interested in seeing.
I just unchecked the two bottom ones.
Runs correctly. Had three scripts being run. Awesome. Thanks for your patience and help! Both extras have been removed.
Yah, I figured when I was able to actually hear what you meant about where to look. Sorry bit slow sometimes, here. However usually pretty good about things like that once i have a good learning experience like this one to show me what moving the script up on the camera multiple times will end up doing… Just got used to blenders UI and now onwards with this… So many UIs to get familiar with. Thanks again.