2

私は、3D アンビエントで移動するキャラクターで構成されたモバイル ゲームを作成しようとしています (エンドレス ランナーについて考えてみてください。ただし、真っ直ぐに走るだけではなく、下に行ったり、右上に左に行ったり、180 度の曲線を描いたりすることもできます)。右の動きが可能で、私の場合は 9 つあります ( 3x3 グリッドについて考えてください) 。

問題の説明:

は ItweenPathを使用します

私のカメラはキャラクターの子です(つまり、キャラクターの動きと回転を模倣します)パスをたどります(パスを見て、パスが下に行くとキャラクターとカメラが下を向くようにします)が、彼が近づいたり入ったりするとこのような180 度の曲線-> ) <-- (上/下の動き/ x軸) 曲線の中央で、単純にパスをたどるのではなく、180 度のフリップ(左/右の動き/ y軸) を行います。

なぜそれが問題なのですか?その曲線の最後では、私のキャラクター (およびカメラ) が上下逆になっている必要がありますが、そうではありません。たとえば、パスを変更するときに、正しいパスに変更したい場合は、左矢印をクリックする必要があるためです。文字が正しい位置の上下逆になっています (要点はわかりましたか?)

PS: 私は簡単な修正を行いましたが、それは将来に向けていくつかの問題を提示します: フリッピングポイントでパスを反対側に切り替えました (したがって、反転するとすべてのパスが交差します) 可能であれば回避したいと思います

コードは次のとおりです。

//info about the paths:
             iTween.Hash("path", iTweenPath.GetPath("MidPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear );    
             iTween.Hash("path", iTweenPath.GetPath("LeftPath"), "time",tempoTotal ,"orienttopath", true, "easetype", iTween.EaseType.linear);    
             iTween.Hash("path", iTweenPath.GetPath("RightPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);
             iTween.Hash("path", iTweenPath.GetPath("UpMidPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);    
             iTween.Hash("path", iTweenPath.GetPath("UpLeftPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);    
             iTween.Hash("path", iTweenPath.GetPath("UpRightPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);
             iTween.Hash("path", iTweenPath.GetPath("DownMidPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);    
             iTween.Hash("path", iTweenPath.GetPath("DownLeftPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);    
             iTween.Hash("path", iTweenPath.GetPath("DownRightPath"), "time",tempoTotal ,"orienttopath", true,  "easetype", iTween.EaseType.linear);
             //Storing the position of path nodes in arrays, my character travel will be guided by those:
             pathM = iTweenPath.GetPath ("MidPath");
             pathL = iTweenPath.GetPath ("LeftPath");
             pathR = iTweenPath.GetPath ("RightPath");
             pathUM = iTweenPath.GetPath ("UpMidPath");
             pathUL = iTweenPath.GetPath ("UpLeftPath");
             pathUR = iTweenPath.GetPath ("UpRightPath");
             pathDM = iTweenPath.GetPath ("DownMidPath");
             pathDL = iTweenPath.GetPath ("DownLeftPath");
             pathDR = iTweenPath.GetPath ("DownRightPath");

//i use this to change the path..
             strPath = "mid";
             currPath = pathM;

(...)
//This is the calculation
//countTime -> time passed since start (i see the percent of path travelled by the time in sec)
//percent -> percent of path completed
//futurePercent -> used to make a prediction of the percent when i change path (the character doesnt stop moving when changing paths)
//futureRotate -> this is used to make the character face/look at the path in FRONT of him
//possible -> if the character is on the leftest path he cant go left anymore.
     countTime += Time.deltaTime; //Tempo
         percent = (countTime / tempoTotal)-0.001f;
         futurePercent =((tempoTroca+countTime) / tempoTotal)-0.001f; 
         futureRotate =(countTime / tempoTotal)+0.201f;
         possible=false;

//InputKeys to change path
//stuff -> the position of the other path that character will move to
         if (Input.GetKeyDown(KeyCode.LeftArrow)) {
             if (strPath == "right") {
                 possible = true;
                 currPath = pathM;
                 strPath = "mid";
                 stuff = iTween.PointOnPath(iTweenPath.GetPath("MidPath"), futurePercent);


//THE PROBLEM IS PROBABLY HERE
  if (move == true && countTime >= timeFixed-(tempoTroca/2)) {//this works when character changes path
          stuff = iTween.PointOnPath(currPath, futureRotate); //get the position where it will move
          iTween.LookTo (gameObject, iTween.Hash("looktarget", stuff, "time", tempoTroca/2));//looks at it
}

   if (move == false || countTime > timeFixed) {//this wont be running if the character is changing path
          move = false;
stuff = iTween.PointOnPath(currPath, futureRotate);
          iTween.LookUpdate (gameObject, iTween.Hash("axis", "x","looktarget", stuff, "time", lookTime)); //constantly looking at the path

          if (countTime <= tempoTotal)
          iTween.PutOnPath (gameObject, currPath, percent); //makes character move
     }

また、問題はおそらく iTweenPAth 自体にあると思います。逆さまになることを拒否します。これは、X 軸で 360 度の曲線 (正確には円) を作成し、キャラクターが Y 軸で (瞬間的な) 180 度の反転を行うためです。

長いテキストで申し訳ありませんが、誰かがこの闘争で私を助けてくれることを願っています

4

0 に答える 0