- Home /
Different programming in Flash?
Hi!
I would like to ask if anyone noticed if there is a difference in code-handling in Standalone/WebPlayer and Flash export?
I have a code which at first runs well, then when i reset some variables, it goes crazy and handles the 'if' statements badly. It runs well on Win Standalone and WebPlayer, but not on Flash.
Here is a part of the code:
if (Input.GetMouseButtonUp(0) && distance == 0) {
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray,hit)) {
if(!first && !second){
hitpos1 = hit.point;
first = true;
}
else if(first && !second){
hitpos2 = hit.point;
second = true;
}
if(first && second){
measuredistance();
}
}
}
function measuredistance(){
dot1 = Instantiate(dotmodel,hitpos1+Vector3(0,0.05,0),Quaternion.identity);
dot2 = Instantiate(dotmodel,hitpos2+Vector3(0,0.05,0),Quaternion.identity);
distance = Vector3.Distance(hitpos1,hitpos2);
linerenderer = GetComponent(LineRenderer);
linerenderer.SetPosition(0,hitpos1+Vector3(0,0.05,0));
linerenderer.SetPosition(1,hitpos2+Vector3(0,0.05,0));
hitpos1 = hitpos2 = Vector3(0.0,0.0,0.0);
}
This runs fine at first, it spawns the dots at the places i clicked, and measures the distance between them, draws the line, but then when i reset the variables 'first' and 'second' (they are boolean) with a button and try again, the problems begin, because if i click with the mouse, 'hitpos1' and 'hitpos2' instantly gets the same value. The variable 'second' remains false, but 'hitpos2' changes. I see that, because i have on screen display of the variables for debugging purposes.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Rotation problem 1 Answer
Very little, but very heavy script problem. 0 Answers
I can't go to unify wiki 2 Answers
Ref modifier 1 Answer