Hello Members,
I have added two object (.obj) file.Both object are moving on navMesh. On right click 1st object is moving. on Left click 2nd object is moving. Click means target position of that object.
I am facing a problem if I click right 1st object is moving between moving the object If I pressed left click 2nd object is moving but 1st object is stop without reaching to target position. Video . jsfiddle
Take a look at the source code of this example. Though it was made with r73, it uses the conception of what I’m talking about. There are three objects, each of them contains several properties, including an object of a sphere and update() function. The code is not so perfect (I rather would say that it’s imperfect), but it does what it was meant to do.
The problem is you just need to organize your code better: You have global variables, and when you click or right click, you are overriding them. calculatedPath for example is modified when you click or right click. You’re overriding variables that each character needs for the path.
You should organize your code so that each character has it’s own calculated path variable. One way you can do this is to make separate variables for each character like calculatedPath1, calculatedPath2, etc.
Another way to organize is to learn how to make JavaScript classes, and store the information in separate instances of your classes. For example, you might store path information for each character on the instance of the character.
If all your target environment support class {} syntax, learn how to use that. If your target environments don’t all support class syntax, then learn the old traditional “JavaScript constructor patterns” (the same pattern all Three.js classes are made with).
You should organize your code so that each character has it’s own calculated path variable. One way you can do this is to make separate variables for each character like calculatedPath1, calculatedPath2, etc.
this method worked fine,but number of lines increased, How i can used one method for multiple cars