Alright, so I've put in an interact function for an object. Once the object is interacted with, a variable goes up by one. Interacting with it again is supposed to produce a different interaction because of the variable, but the problem is, when it's interacted with once, the second interaction plays automatically without the need for a second click.
How can I fix this?
Thanks in advance :)
Looks like you have a broken conditional statement there, but it's hard to tell without seeing the code.
It SHOULD be something line this (in order to WORK)
function ObjectInteraction()
{
if (timesInteracted == 0)
{
timesInteracted++;
player.Say("This is the first time my grubby fingers are touching this!");
}
else
{
player.Say("Aha! Something has changed and it feels totally different now!");
}
}
Apart from that, your actual mouse-click script could be broken- are you calling it from more than one script file maybe?
In any case; probably best to post the code :)
If guess you have something like this:
if (counter == 0) {
// blah, stuff
counter++;
}
if (counter == 1) {
// blah, other stuff
}
Obviously, by the time the second if is reached, counter was already incremented. Like Ghost says, use an "else". Or swap the two blocks. Or add a "return;" to the end of the first.
Thanks guys, I think that should work.
EDIT: Yep, just using an else worked. I was confused because I required the player to interact with it about 6 times, but it did work.
Cheers!
If those 6 times are reproducible, and not due to you clicking next to the object, there's still something wrong with your code.
As a general note: post. your. code.