Jump to content

how to set position values to dynamic javascript ID


JS-KMM
 Share

Recommended Posts

I want to set the position for particular ID's.In above my code i have created id for each coins

I hae tried

var xa = 100;
                            var ya = 5;
                            var za = 25;

 for(j ; j < (ballcount + 5); j++)
                    {              
                        coin[j];

                        coin[j].id.position = new BABYLON.Vector3(xa, ya, za);
                        coin[j].id.material = coinMaterial;
                        }
                        ballcount = ballcount + 5;                        
                            if (j < 5) {
                                xa = (xa - (100 / 5));
                            } else if (j < 10) {
                                xa = (xa - (100 / 7.5));
                            } else if (j < 15) {
                                xa = (xa - (100 / 6.5));
                            } else if (j < 20) {
                                xa = (xa - (100 / 5));
                            } else if (j < 25) {
                                xa = (xa - (100 / 5));
                            } else if (j < 30) {
                                xa = (xa - (100 / 5));
                            } else if (j < 35) {
                                xa = (xa - (100 / 5));
                            } else if (j < 40) {
                                xa = xa + 15; //- (100 / 90));
                            } else if (j < 45) {
                                xa = (xa - 18);
                            } else if (j < 50) {
                                xa = (xa - 20);
                            } else if (j < 55) {
                                xa = (xa - 18);
                            } else if (j < 60) {
                                xa = (xa - 18);
                            } else if (j < 65) {
                                xa = (xa - 20);
                            } else {
                                 xa = (xa - 20);
                            }

Link to comment
Share on other sites

Where is j set?

what is ballcount?

Please elaborate.

 

Despite the missing information.. i gave it a go anyway.

I don't know if this is what you're looking for, but atleast it's a working piece of code now :)

  //Variables.
  var xa = 100, ya = 5, za = 25;

  //add 5 to ball count..?
  ballcount += 5;

  for(var j = 0; j < ballcount; j++)
  {
    //Make dummy variable for xa instead of editing the global xa variable.
    var xa2;

    if (j < 5) {
      xa2 = (xa - (100 / 5));
    } else if (j < 10) {
      xa2 = (xa - (100 / 7.5));
    } else if (j < 15) {
      xa2 = (xa - (100 / 6.5));
    } else if (j < 20) {
      xa2 = (xa - (100 / 5));
    } else if (j < 25) {
      xa2 = (xa - (100 / 5));
    } else if (j < 30) {
      xa2 = (xa - (100 / 5));
    } else if (j < 35) {
      xa2 = (xa - (100 / 5));
    } else if (j < 40) {
      xa2 = xa + 15; //- (100 / 90));
    } else if (j < 45) {
      xa2 = (xa - 18);
    } else if (j < 50) {
      xa2 = (xa - 20);
    } else if (j < 55) {
      xa2 = (xa - 18);
    } else if (j < 60) {
      xa2 = (xa - 18);
    } else if (j < 65) {
      xa2 = (xa - 20);
    } else {
      xa2 = (xa - 20);
    }

    coin[j].id.position = new BABYLON.Vector3(xa2, ya, za);
    coin[j].id.material = coinMaterial;
  }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...