- Home /
Question by
Reeceg · Mar 06, 2015 at 12:29 AM ·
javascriptnot workingwaypoints
No reason why this shouldent work
This script wont set the variables to anything the way it should. It is in the plugins folder.
var distance = Vector3.Distance(wayPoint.transform.position, transform.position);
var distance2 = Vector3.Distance(wayPoint2.transform.position, transform.position);
var distance3 = Vector3.Distance(wayPoint3.transform.position, transform.position);
test = distance;
if (distance < distance2 && distance < distance3)
{
currentWayPoint = wayPoint;
}
if (distance2 < distance && distance2 < distance3)
{
currentWayPoint = wayPoint2;
}
if (distance3 < distance && distance3 < distance2)
{
currentWayPoint = wayPoint3;
}
if (stage01)
{
wayPoint = wayPoint01;
wayPoint2 = wayPoint21;
wayPoint3 = wayPoint31;
}
if (stage02)
{
wayPoint = wayPoint02;
wayPoint2 = wayPoint22;
wayPoint3 = wayPoint32;
}
if (stage03)
{
wayPoint = wayPoint03;
wayPoint2 = wayPoint23;
wayPoint3 = wayPoint33;
}
if (stage04)
{
wayPoint = wayPoint04;
wayPoint2 = wayPoint24;
wayPoint3 = wayPoint34;
}
if (stage05)
{
wayPoint = wayPoint05;
wayPoint2 = wayPoint25;
wayPoint3 = wayPoint35;
}
if (stage06)
{
wayPoint = wayPoint06;
wayPoint2 = wayPoint26;
wayPoint3 = wayPoint36;
}
if (stage07)
{
wayPoint = wayPoint07;
wayPoint2 = wayPoint27;
wayPoint3 = wayPoint37;
}
if (stage08)
{
wayPoint = wayPoint08;
wayPoint2 = wayPoint28;
wayPoint3 = wayPoint38;
}
if (stage09)
{
wayPoint = wayPoint09;
wayPoint2 = wayPoint29;
wayPoint3 = wayPoint39;
}
Comment
I don't get how this works if the inspector override's stuff in scripts then nothing would ever work the script would never be able to change stuff.
What do you mean define the way it should, the way it should change? if so the way it should change is when stage01 is true the waypoints should change but that dont.
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
why won't my code work? 1 Answer
Why isn't my animation being played? 0 Answers
Move at mouse click 0 Answers
Variable won't appear on UI text (JS) 0 Answers