Cc.v3 in new creator 2.1.0 and cc.v2 do not work well together!

Cc.v3 in new creator 2.1.0 and cc.v2 do not work well together!


With the new render system preparing for 3D games in future (i think so), the node.position now return cc.v3 object instead of cc.v2 and my troubles come from here.

Let’s say that i’ve 2 nodes and i’d like to calculate distance between them to make motion effect (Ex: earned coin move from enemy to UI), and these 2 nodes stay in different containers () and i do as below:

  1. Convert enemy position from its container to coin’s container by convertToNodeSpaceAR function and this return cc.v2 same as older cocos version. (called enemyPos)
  2. Get coin’s position by call node.position and this return cc.v3 object instead of cc.v2 object as older cocos version. (called coinPos)
  3. Now calling coinPos.sub(enemyPos).mag() return NaN value and things go wrong!!!

I can handle this trouble by doing a simple convert cc.v2<=>cc.v3 but it’s not sense and so so conflict. Where return cc.v2? Where return cc.v3? Which functions these 2 objects work together? How many conflict APIs between 2D and 3D functions stays there? I’ve a little bit of worry!!!

Read this it should help


at the document choose Version2.1 to check 3d’s api and tips


It does not help too much, the problem stay in function convertToNodeSpaceAR. It return cc.v2 object while Node.position return cc.v3 object. I think it’s better if cc.v2 is deprecated, it’s just cc.v3(x, y, 0).


If you are interacting a 2d and a 3d node, conversion of v2 to v3 (or v3 to v2) is a must. But that does not mean we should just remove v2 as there are ppl still using it for 2d games.