|
Hello everyone, i need 3 instances of an object at 3 different positions on the x axis between x = - 4 and x = 4. Then in another script, i need these 4 objects to start a ping pong movement along the x axis. So it seems i need a static array variable. I created this code but unity gives me lots of errors. Can you help me? Script 1 (named GameController.js) Script 2 (named EnemyMovement.js)
(comments are locked)
|
|
You first created a static variable named xpos of type float[], but then try to read it as a float (not an array). You may need to change your script this way (it is just a suggestion): Script 1 (named GameController.js) Script 2 (named EnemyMovement.js) it worked in a strange way, the istances teleport at the same position on the x axis and then start moving (following the same path).
Jul 13 '12 at 02:05 PM
Mz3D
This line is responsible for it (and IMHO it does not make sense): I just pointed out the modification needed for the script to run. But you may have to review the logic. The first parameter of Math.PingPong should be a time not a position.
Jul 13 '12 at 02:16 PM
Kryptos
i tried to change the code as this but the result is the same function Update () { transform.position.x = Mathf.PingPong (Time.time, 8.0); }
Jul 13 '12 at 02:56 PM
Mz3D
i tried to change the code as this but the result is the same
Jul 13 '12 at 03:04 PM
Mz3D
(comments are locked)
|
